JavaScript Object hasOwnProperty() Method Last Updated : 12 Jul, 2025 Comments Improve Suggest changes 7 Likes Like Report The hasOwnProperty() method in JavaScript checks if an object has a specific property as its own (not inherited). It returns true if the property exists directly on the object, otherwise false, making it useful for distinguishing own properties from inherited ones.Syntaxobject.hasOwnProperty( prop );Parameters:prop: It holds the name in the form of a String or a Symbol of the property to test.Return Value:It returns a Boolean value indicating whether the object has the given property as its own property.Example 1: In this example, the hasOwnProperty() method checks if the exampleObj contains the properties "height" (which exists) and "breadth" (which doesn't exist). It returns true for "height" and false for "breadth". JavaScript let exampleObj = {}; exampleObj.height = 100; exampleObj.width = 100; // Checking for existing property let result1 = exampleObj.hasOwnProperty("height"); // Checking for non-existing property let result2 = exampleObj.hasOwnProperty("breadth"); console.log(result1); // true console.log(result2); // false Outputtrue false Example 2: In this example The checkProperty() function creates a Car object and checks if the model property exists (true) and if the wheels property doesn't exist (false) using the hasOwnProperty() method. JavaScript function checkProperty() { function Car(a, b) { this.model = a; this.name = b; } let car1 = new Car("Mazda", "Laputa"); // Checking for existing property result1 = car1.hasOwnProperty("model"); // Checking for non-existing property result2 = car1.hasOwnProperty("wheels"); console.log(result1); console.log(result2); } checkProperty() Outputtrue false We have a complete list of Object methods, and properties to check those please go through this JavaScript Object Complete Reference article.Supported Browsers: Google Chrome Firefox Edge Safari Opera Create Quiz Comment S sayantanm19 Follow 7 Improve S sayantanm19 Follow 7 Improve Article Tags : JavaScript Web Technologies javascript-object JavaScript-Methods Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like