{"id":175,"date":"2026-05-06T16:38:31","date_gmt":"2026-05-06T16:38:31","guid":{"rendered":"https:\/\/gigz.pk\/javascript\/?post_type=lesson&#038;p=175"},"modified":"2026-05-06T16:38:32","modified_gmt":"2026-05-06T16:38:32","slug":"prototype-chain","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/javascript\/?lesson=prototype-chain","title":{"rendered":"Prototype Chain"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Introduction<br>The prototype chain is a fundamental concept in JavaScript that allows objects to inherit properties and methods from other objects. It is the mechanism behind JavaScript\u2019s inheritance system and helps developers write more efficient and reusable code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What is the Prototype Chain<br>In JavaScript, every object has a hidden internal property called [[Prototype]]. This property links to another object. When you try to access a property or method, JavaScript first looks at the object itself. If it does not find it, it moves up the prototype chain until it finds the property or reaches null.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This chain of objects is called the prototype chain.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">How the Prototype Chain Works<br>When a property is accessed, JavaScript follows these steps<br>First it checks the object itself<br>If not found, it checks the object\u2019s prototype<br>It continues searching up the chain<br>If the property is not found, it returns undefined<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example of Prototype Chain<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function Person(name) {<br>  this.name = name;<br>}<br><br>Person.prototype.greet = function() {<br>  return \"Hello \" + this.name;<br>};<br><br>const user = new Person(\"Ali\");<br><br>console.log(user.greet());<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, the greet method is not inside the user object directly. It is inherited from Person.prototype through the prototype chain.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Importance of Prototype Chain<br>The prototype chain helps reduce memory usage because methods are shared instead of duplicated<br>It allows code reuse and cleaner structure<br>It forms the base of object oriented programming in JavaScript<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Common Methods Related to Prototype<br>Object.create is used to create a new object with a specified prototype<br>Object.getPrototypeOf returns the prototype of an object<br>hasOwnProperty checks if a property belongs directly to an object<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Best Practices<br>Avoid modifying built in object prototypes<br>Use prototypes to share methods across instances<br>Understand the chain to debug property access issues<br>Use modern class syntax when appropriate but still understand prototypes behind the scenes<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Conclusion<br>The prototype chain is a powerful feature that enables inheritance in JavaScript. By understanding how it works, developers can build scalable and efficient applications with better performance and maintainable code.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/javascript\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">Professional JavaScript > Advanced Concepts > Prototype Chain<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1778085488455\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1778085488214\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n","protected":false},"menu_order":0,"template":"","class_list":["post-175","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Prototype Chain - Learn JavaScript with GIGZ.PK<\/title>\n<meta name=\"description\" content=\"Learn JavaScript prototype chain to understand inheritance, object linking, and property lookup for better coding skills\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/javascript\/?lesson=prototype-chain\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Prototype Chain - Learn JavaScript with GIGZ.PK\" \/>\n<meta property=\"og:description\" content=\"Learn JavaScript prototype chain to understand inheritance, object linking, and property lookup for better coding skills\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/javascript\/?lesson=prototype-chain\" \/>\n<meta property=\"og:site_name\" content=\"Learn JavaScript with GIGZ.PK\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-06T16:38:32+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\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\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=prototype-chain\",\"url\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=prototype-chain\",\"name\":\"Prototype Chain - Learn JavaScript with GIGZ.PK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/#website\"},\"datePublished\":\"2026-05-06T16:38:31+00:00\",\"dateModified\":\"2026-05-06T16:38:32+00:00\",\"description\":\"Learn JavaScript prototype chain to understand inheritance, object linking, and property lookup for better coding skills\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=prototype-chain#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=prototype-chain\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=prototype-chain#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/javascript\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Professional JavaScript > Advanced Concepts > Prototype Chain\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/\",\"name\":\"Learn JavaScript with GIGZ.PK\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Prototype Chain - Learn JavaScript with GIGZ.PK","description":"Learn JavaScript prototype chain to understand inheritance, object linking, and property lookup for better coding skills","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:\/\/gigz.pk\/javascript\/?lesson=prototype-chain","og_locale":"en_US","og_type":"article","og_title":"Prototype Chain - Learn JavaScript with GIGZ.PK","og_description":"Learn JavaScript prototype chain to understand inheritance, object linking, and property lookup for better coding skills","og_url":"https:\/\/gigz.pk\/javascript\/?lesson=prototype-chain","og_site_name":"Learn JavaScript with GIGZ.PK","article_modified_time":"2026-05-06T16:38:32+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/javascript\/?lesson=prototype-chain","url":"https:\/\/gigz.pk\/javascript\/?lesson=prototype-chain","name":"Prototype Chain - Learn JavaScript with GIGZ.PK","isPartOf":{"@id":"https:\/\/gigz.pk\/javascript\/#website"},"datePublished":"2026-05-06T16:38:31+00:00","dateModified":"2026-05-06T16:38:32+00:00","description":"Learn JavaScript prototype chain to understand inheritance, object linking, and property lookup for better coding skills","breadcrumb":{"@id":"https:\/\/gigz.pk\/javascript\/?lesson=prototype-chain#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/javascript\/?lesson=prototype-chain"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/javascript\/?lesson=prototype-chain#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/javascript"},{"@type":"ListItem","position":2,"name":"Professional JavaScript > Advanced Concepts > Prototype Chain"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/javascript\/#website","url":"https:\/\/gigz.pk\/javascript\/","name":"Learn JavaScript with GIGZ.PK","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/javascript\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=\/wp\/v2\/lesson\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}