{"id":265976,"date":"2025-01-20T05:22:02","date_gmt":"2025-01-20T04:22:02","guid":{"rendered":"https:\/\/glosarix.com\/glossary\/object-prototype-hasownproperty-en\/"},"modified":"2025-01-20T05:22:02","modified_gmt":"2025-01-20T04:22:02","slug":"object-prototype-hasownproperty-en","status":"publish","type":"glossary","link":"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/","title":{"rendered":"Object.prototype.hasOwnProperty"},"content":{"rendered":"<p>Description: The &#8216;Object.prototype.hasOwnProperty&#8217; method is a fundamental function in JavaScript that allows checking if an object has a specific property as its own property, meaning it is not inherited from its prototype. This method returns a boolean value: &#8216;true&#8217; if the property exists on the object and &#8216;false&#8217; otherwise. Its use is crucial to avoid confusion between own and inherited properties, especially when manipulating complex objects. Being a prototype method, it is available to all objects in JavaScript, making it a versatile and widely used tool in programming. The basic syntax is &#8216;object.hasOwnProperty(property)&#8217;, where &#8216;object&#8217; is the object being evaluated and &#8216;property&#8217; is a string representing the name of the property to check. This method is particularly useful in situations where developers work with objects that may have properties added through inheritance, ensuring that only properties that belong directly to the object in question are accessed.<\/p>\n<p>History: The &#8216;hasOwnProperty&#8217; method was introduced in the first edition of ECMAScript in 1997. Since then, it has been an integral part of the language, evolving with later versions of ECMAScript. Its inclusion in the standard was a response to the need to handle property inheritance in objects, a fundamental concept in object-oriented programming that JavaScript implements.<\/p>\n<p>Uses: The &#8216;hasOwnProperty&#8217; method is commonly used in object iteration, especially when using loops like &#8216;for&#8230;in&#8217;. It allows developers to filter out inherited properties and focus only on the object&#8217;s own properties. It is also useful in data validation, ensuring that certain properties exist before performing operations on them.<\/p>\n<p>Examples: A practical example of &#8216;hasOwnProperty&#8217; would be the following: var obj = {a: 1}; console.log(obj.hasOwnProperty(&#8216;a&#8217;)); \/\/ true. In this case, the method returns &#8216;true&#8217; because &#8216;a&#8217; is an own property of the &#8216;obj&#8217; object. If an inherited property is added, such as in &#8216;Object.prototype.b = 2;&#8217;, and &#8216;obj.hasOwnProperty(&#8216;b&#8217;)&#8217; is checked, the result will be &#8216;false&#8217;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: The &#8216;Object.prototype.hasOwnProperty&#8217; method is a fundamental function in JavaScript that allows checking if an object has a specific property as its own property, meaning it is not inherited from its prototype. This method returns a boolean value: &#8216;true&#8217; if the property exists on the object and &#8216;false&#8217; otherwise. Its use is crucial to avoid [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"glossary-categories":[12040],"glossary-tags":[12996],"glossary-languages":[],"class_list":["post-265976","glossary","type-glossary","status-publish","hentry","glossary-categories-javascript-en","glossary-tags-javascript-en"],"post_title":"Object.prototype.hasOwnProperty ","post_content":"Description: The 'Object.prototype.hasOwnProperty' method is a fundamental function in JavaScript that allows checking if an object has a specific property as its own property, meaning it is not inherited from its prototype. This method returns a boolean value: 'true' if the property exists on the object and 'false' otherwise. Its use is crucial to avoid confusion between own and inherited properties, especially when manipulating complex objects. Being a prototype method, it is available to all objects in JavaScript, making it a versatile and widely used tool in programming. The basic syntax is 'object.hasOwnProperty(property)', where 'object' is the object being evaluated and 'property' is a string representing the name of the property to check. This method is particularly useful in situations where developers work with objects that may have properties added through inheritance, ensuring that only properties that belong directly to the object in question are accessed.\n\nHistory: The 'hasOwnProperty' method was introduced in the first edition of ECMAScript in 1997. Since then, it has been an integral part of the language, evolving with later versions of ECMAScript. Its inclusion in the standard was a response to the need to handle property inheritance in objects, a fundamental concept in object-oriented programming that JavaScript implements.\n\nUses: The 'hasOwnProperty' method is commonly used in object iteration, especially when using loops like 'for...in'. It allows developers to filter out inherited properties and focus only on the object's own properties. It is also useful in data validation, ensuring that certain properties exist before performing operations on them.\n\nExamples: A practical example of 'hasOwnProperty' would be the following: var obj = {a: 1}; console.log(obj.hasOwnProperty('a')); \/\/ true. In this case, the method returns 'true' because 'a' is an own property of the 'obj' object. If an inherited property is added, such as in 'Object.prototype.b = 2;', and 'obj.hasOwnProperty('b')' is checked, the result will be 'false'.","yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Object.prototype.hasOwnProperty - Glosarix<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Object.prototype.hasOwnProperty - Glosarix\" \/>\n<meta property=\"og:description\" content=\"Description: The &#8216;Object.prototype.hasOwnProperty&#8217; method is a fundamental function in JavaScript that allows checking if an object has a specific property as its own property, meaning it is not inherited from its prototype. This method returns a boolean value: &#8216;true&#8217; if the property exists on the object and &#8216;false&#8217; otherwise. Its use is crucial to avoid [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/\" \/>\n<meta property=\"og:site_name\" content=\"Glosarix\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@GlosarixOficial\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/\",\"url\":\"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/\",\"name\":\"Object.prototype.hasOwnProperty - Glosarix\",\"isPartOf\":{\"@id\":\"https:\/\/glosarix.com\/en\/#website\"},\"datePublished\":\"2025-01-20T04:22:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/glosarix.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Object.prototype.hasOwnProperty\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/glosarix.com\/en\/#website\",\"url\":\"https:\/\/glosarix.com\/en\/\",\"name\":\"Glosarix\",\"description\":\"T\u00e9rminos tecnol\u00f3gicos - Glosarix\",\"publisher\":{\"@id\":\"https:\/\/glosarix.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/glosarix.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/glosarix.com\/en\/#organization\",\"name\":\"Glosarix\",\"url\":\"https:\/\/glosarix.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/glosarix.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/glosarix.com\/wp-content\/uploads\/2025\/04\/Glosarix-logo-192x192-1.png.webp\",\"contentUrl\":\"https:\/\/glosarix.com\/wp-content\/uploads\/2025\/04\/Glosarix-logo-192x192-1.png.webp\",\"width\":192,\"height\":192,\"caption\":\"Glosarix\"},\"image\":{\"@id\":\"https:\/\/glosarix.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/GlosarixOficial\",\"https:\/\/www.instagram.com\/glosarixoficial\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Object.prototype.hasOwnProperty - Glosarix","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/","og_locale":"en_US","og_type":"article","og_title":"Object.prototype.hasOwnProperty - Glosarix","og_description":"Description: The &#8216;Object.prototype.hasOwnProperty&#8217; method is a fundamental function in JavaScript that allows checking if an object has a specific property as its own property, meaning it is not inherited from its prototype. This method returns a boolean value: &#8216;true&#8217; if the property exists on the object and &#8216;false&#8217; otherwise. Its use is crucial to avoid [&hellip;]","og_url":"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/","og_site_name":"Glosarix","twitter_card":"summary_large_image","twitter_site":"@GlosarixOficial","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/","url":"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/","name":"Object.prototype.hasOwnProperty - Glosarix","isPartOf":{"@id":"https:\/\/glosarix.com\/en\/#website"},"datePublished":"2025-01-20T04:22:02+00:00","breadcrumb":{"@id":"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/glosarix.com\/en\/glossary\/object-prototype-hasownproperty-en\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/glosarix.com\/en\/"},{"@type":"ListItem","position":2,"name":"Object.prototype.hasOwnProperty"}]},{"@type":"WebSite","@id":"https:\/\/glosarix.com\/en\/#website","url":"https:\/\/glosarix.com\/en\/","name":"Glosarix","description":"T\u00e9rminos tecnol\u00f3gicos - Glosarix","publisher":{"@id":"https:\/\/glosarix.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/glosarix.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/glosarix.com\/en\/#organization","name":"Glosarix","url":"https:\/\/glosarix.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/glosarix.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/glosarix.com\/wp-content\/uploads\/2025\/04\/Glosarix-logo-192x192-1.png.webp","contentUrl":"https:\/\/glosarix.com\/wp-content\/uploads\/2025\/04\/Glosarix-logo-192x192-1.png.webp","width":192,"height":192,"caption":"Glosarix"},"image":{"@id":"https:\/\/glosarix.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/GlosarixOficial","https:\/\/www.instagram.com\/glosarixoficial\/"]}]}},"_links":{"self":[{"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary\/265976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary"}],"about":[{"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/types\/glossary"}],"author":[{"embeddable":true,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/comments?post=265976"}],"version-history":[{"count":0,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary\/265976\/revisions"}],"wp:attachment":[{"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/media?parent=265976"}],"wp:term":[{"taxonomy":"glossary-categories","embeddable":true,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary-categories?post=265976"},{"taxonomy":"glossary-tags","embeddable":true,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary-tags?post=265976"},{"taxonomy":"glossary-languages","embeddable":true,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary-languages?post=265976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}