{"id":3090,"date":"2025-10-20T08:57:50","date_gmt":"2025-10-20T07:57:50","guid":{"rendered":"https:\/\/codeflarelimited.com\/blog\/?p=3090"},"modified":"2025-10-20T08:57:53","modified_gmt":"2025-10-20T07:57:53","slug":"javascript-prototypes-and-inheritance","status":"publish","type":"post","link":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/","title":{"rendered":"JavaScript Prototypes And Inheritance"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>JavaScript is a\u00a0<strong>prototype-based<\/strong>\u00a0language, which means that inheritance \u2014 the mechanism that allows one object to access properties and methods of another \u2014 is implemented through\u00a0<strong>prototypes<\/strong>, not classical classes (though the\u00a0<code>class<\/code>syntax introduced in ES6 provides a cleaner abstraction over it).<\/p>\n\n\n\n<p><a href=\"https:\/\/apps.apple.com\/us\/app\/codeflare\/id1622809632\">Download the Codeflare Mobile for iOS<\/a><\/p>\n\n\n\n<p>In simple terms:<\/p>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p>Every object in JavaScript can have another object as its\u00a0<strong>prototype<\/strong>, from which it inherits properties and methods.<\/p><\/blockquote><\/figure>\n\n\n\n<p><a href=\"https:\/\/codeflarelimited.com\">Start Learning JavaScript<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding Prototypes<\/h2>\n\n\n\n<p>Every JavaScript object has an internal link to another object called its&nbsp;<strong>prototype<\/strong>.<br>This prototype object is referenced by the special property&nbsp;<code>[[Prototype]]<\/code>&nbsp;(or&nbsp;<code>__proto__<\/code>&nbsp;in most environments).<\/p>\n\n\n\n<p>When you try to access a property on an object and it\u2019s not found, JavaScript looks\u00a0<strong>up the prototype chain<\/strong>\u00a0\u2014 the object\u2019s prototype, then the prototype\u2019s prototype, and so on \u2014 until it finds it or reaches the end of the chain (<code>null<\/code>).<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">const person = {\n  greet() {\n    console.log(\"Hello!\");\n  }\n};\n\nconst student = Object.create(person); \/\/ student inherits from person\nstudent.study = function() {\n  console.log(\"Studying...\");\n};\n\nstudent.greet(); \/\/ Output: Hello! (inherited from person)\nstudent.study(); \/\/ Output: Studying...\n<\/code><\/pre>\n\n\n\n<p>In the example above:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>student<\/code>\u00a0inherits from\u00a0<code>person<\/code>\u00a0via\u00a0<code>Object.create()<\/code>.<\/li>\n\n\n\n<li>When\u00a0<code>student.greet()<\/code>\u00a0is called, JavaScript doesn\u2019t find\u00a0<code>greet<\/code>\u00a0on\u00a0<code>student<\/code>, so it looks up to its prototype \u2014\u00a0<code>person<\/code>\u00a0\u2014 and finds it there.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">The Prototype Chain \ud83e\uddec<\/h2>\n\n\n\n<p>Here\u2019s how the lookup works internally:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">student \u2192 person \u2192 Object.prototype \u2192 null<\/code><\/pre>\n\n\n\n<p>Each arrow represents the prototype link.<br>When you create a new object, its prototype determines what it can inherit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Constructor Functions and Prototypes<\/h2>\n\n\n\n<p>Before ES6\u00a0<code>class<\/code>\u00a0syntax,\u00a0<strong>constructor functions<\/strong>\u00a0were used to create objects that share methods through their prototype.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">function Car(make, model) {\n  this.make = make;\n  this.model = model;\n}\n\n\/\/ Add method to Car's prototype\nCar.prototype.start = function() {\n  console.log(`${this.make} ${this.model} started.`);\n};\n\nconst car1 = new Car(\"Toyota\", \"Camry\");\nconst car2 = new Car(\"Honda\", \"Civic\");\n\ncar1.start(); \/\/ Toyota Camry started.\ncar2.start(); \/\/ Honda Civic started.\n<\/code><\/pre>\n\n\n\n<p>Here\u2019s what happens:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The\u00a0<code>new<\/code>\u00a0keyword creates a new object.<\/li>\n\n\n\n<li>It sets the object\u2019s prototype to\u00a0<code>Car.prototype<\/code>.<\/li>\n\n\n\n<li>It runs the\u00a0<code>Car<\/code>\u00a0function with\u00a0<code>this<\/code>\u00a0bound to the new object.<\/li>\n\n\n\n<li>The object inherits methods from\u00a0<code>Car.prototype<\/code>.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Prototype Inheritance in ES6 Classes<\/h2>\n\n\n\n<p>The ES6&nbsp;<code>class<\/code>&nbsp;syntax is syntactic sugar over the prototype-based model.<br>Under the hood, it still uses prototypes for inheritance.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">class Animal {\n  constructor(name) {\n    this.name = name;\n  }\n\n  speak() {\n    console.log(`${this.name} makes a sound.`);\n  }\n}\n\nclass Dog extends Animal {\n  speak() {\n    console.log(`${this.name} barks.`);\n  }\n}\n\nconst dog = new Dog(\"Buddy\");\ndog.speak(); \/\/ Buddy barks.\n<\/code><\/pre>\n\n\n\n<p>Here\u2019s what happens:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Dog<\/code>\u00a0inherits from\u00a0<code>Animal<\/code>\u00a0via the\u00a0<code>extends<\/code>\u00a0keyword.<\/li>\n\n\n\n<li>The prototype chain becomes:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">dog \u2192 Dog.prototype \u2192 Animal.prototype \u2192 Object.prototype \u2192 null<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Object.create() for Inheritance<\/h2>\n\n\n\n<p>The\u00a0<code>Object.create()<\/code>\u00a0method allows you to create a new object using an existing one as its prototype \u2014 a clean and direct way to set up inheritance without constructors.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">const animal = {\n  speak() {\n    console.log(`${this.name} makes a noise.`);\n  }\n};\n\nconst cat = Object.create(animal);\ncat.name = \"Whiskers\";\ncat.speak(); \/\/ Whiskers makes a noise.\n<\/code><\/pre>\n\n\n\n<p>Here,\u00a0<code>cat<\/code>\u00a0inherits from\u00a0<code>animal<\/code>\u00a0using\u00a0<code>Object.create()<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prototype vs.\u00a0<strong>proto<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>prototype<\/code><\/strong>\u00a0is a property of\u00a0<strong>constructor functions and classes<\/strong>\u00a0\u2014 it defines what will be inherited by instances created with\u00a0<code>new<\/code>.<\/li>\n\n\n\n<li><strong><code>__proto__<\/code><\/strong>\u00a0is the actual prototype of an\u00a0<strong>instance object<\/strong>, pointing to the object it inherits from.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">function Car() {}\nconst myCar = new Car();\n\nconsole.log(Car.prototype === myCar.__proto__); \/\/ true<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Why Use Prototypes?<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Memory efficiency<\/strong>\u00a0\u2013 Shared methods are stored once in the prototype, not duplicated per instance.<\/li>\n\n\n\n<li><strong>Reusability<\/strong>\u00a0\u2013 You can easily extend or modify behaviors by updating prototypes.<\/li>\n\n\n\n<li><strong>Flexibility<\/strong>\u00a0\u2013 Supports dynamic inheritance and extension of objects at runtime.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Summary<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Concept<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><strong>Prototype<\/strong><\/td><td>The object another object inherits from.<\/td><\/tr><tr><td><strong>Prototype Chain<\/strong><\/td><td>The linked chain of prototypes used for property lookup.<\/td><\/tr><tr><td><strong>Constructor Function<\/strong><\/td><td>A function that initializes an object, with shared methods on its prototype.<\/td><\/tr><tr><td><strong>Object.create()<\/strong><\/td><td>Creates an object using another as its prototype.<\/td><\/tr><tr><td><strong>ES6 Classes<\/strong><\/td><td>A syntactic sugar for prototype-based inheritance.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Example: Multi-Level Inheritance<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">class LivingThing {\n  breathe() {\n    console.log(\"Breathing...\");\n  }\n}\n\nclass Animal extends LivingThing {\n  eat() {\n    console.log(\"Eating...\");\n  }\n}\n\nclass Bird extends Animal {\n  fly() {\n    console.log(\"Flying...\");\n  }\n}\n\nconst eagle = new Bird();\neagle.breathe(); \/\/ Breathing...\neagle.eat();     \/\/ Eating...\neagle.fly();     \/\/ Flying...\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Final Thoughts<\/h2>\n\n\n\n<p>JavaScript\u2019s prototype system is&nbsp;<strong>powerful, flexible, and dynamic<\/strong>.<br>Even though&nbsp;<code>class<\/code>&nbsp;syntax feels familiar to developers from other languages,&nbsp;<strong>under the hood it\u2019s still prototypes<\/strong>&nbsp;doing the heavy lifting.<br>Understanding how prototypes and inheritance work allows you to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Write efficient, memory-friendly code.<\/li>\n\n\n\n<li>Build scalable class hierarchies.<\/li>\n\n\n\n<li>Debug and extend JavaScript objects with confidence.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Introduction JavaScript is a\u00a0prototype-based\u00a0language, which means that inheritance \u2014 the mechanism that allows one object to access properties<\/p>\n","protected":false},"author":1,"featured_media":3091,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11],"tags":[],"class_list":["post-3090","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript Prototypes And Inheritance<\/title>\n<meta name=\"description\" content=\"JavaScript is a\u00a0prototype-based\u00a0language, which means that inheritance \u2014 the mechanism that allows one object to access properties\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Prototypes And Inheritance\" \/>\n<meta property=\"og:description\" content=\"JavaScript is a\u00a0prototype-based\u00a0language, which means that inheritance \u2014 the mechanism that allows one object to access properties\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/facebook.com\/codeflretech\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-20T07:57:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-20T07:57:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/10\/2-6.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1080\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"codeflare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codeflaretech\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/\"},\"author\":{\"name\":\"codeflare\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\"},\"headline\":\"JavaScript Prototypes And Inheritance\",\"datePublished\":\"2025-10-20T07:57:50+00:00\",\"dateModified\":\"2025-10-20T07:57:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/\"},\"wordCount\":531,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/2-6.png\",\"articleSection\":[\"javascript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/\",\"name\":\"JavaScript Prototypes And Inheritance\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/2-6.png\",\"datePublished\":\"2025-10-20T07:57:50+00:00\",\"dateModified\":\"2025-10-20T07:57:53+00:00\",\"description\":\"JavaScript is a\u00a0prototype-based\u00a0language, which means that inheritance \u2014 the mechanism that allows one object to access properties\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/#primaryimage\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/2-6.png\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/2-6.png\",\"width\":1080,\"height\":1080,\"caption\":\"javascript prototype and inheritance\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript-prototypes-and-inheritance\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"javascript\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript Prototypes And Inheritance\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"name\":\"\",\"description\":\"Sustainable solutions\",\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\",\"name\":\"Codeflare Limited\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"width\":1040,\"height\":263,\"caption\":\"Codeflare Limited\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\",\"name\":\"codeflare\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"caption\":\"codeflare\"},\"description\":\"Latest tech news and coding tips.\",\"sameAs\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\",\"https:\\\/\\\/facebook.com\\\/codeflretech\",\"https:\\\/\\\/instagram.com\\\/codeflaretech\",\"https:\\\/\\\/x.com\\\/codeflaretech\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1\"],\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/author\\\/watcher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Prototypes And Inheritance","description":"JavaScript is a\u00a0prototype-based\u00a0language, which means that inheritance \u2014 the mechanism that allows one object to access properties","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:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Prototypes And Inheritance","og_description":"JavaScript is a\u00a0prototype-based\u00a0language, which means that inheritance \u2014 the mechanism that allows one object to access properties","og_url":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/","article_author":"https:\/\/facebook.com\/codeflretech","article_published_time":"2025-10-20T07:57:50+00:00","article_modified_time":"2025-10-20T07:57:53+00:00","og_image":[{"width":1080,"height":1080,"url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/10\/2-6.png","type":"image\/png"}],"author":"codeflare","twitter_card":"summary_large_image","twitter_creator":"@codeflaretech","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/#article","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/"},"author":{"name":"codeflare","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a"},"headline":"JavaScript Prototypes And Inheritance","datePublished":"2025-10-20T07:57:50+00:00","dateModified":"2025-10-20T07:57:53+00:00","mainEntityOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/"},"wordCount":531,"commentCount":0,"publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/10\/2-6.png","articleSection":["javascript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/","url":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/","name":"JavaScript Prototypes And Inheritance","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/#primaryimage"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/10\/2-6.png","datePublished":"2025-10-20T07:57:50+00:00","dateModified":"2025-10-20T07:57:53+00:00","description":"JavaScript is a\u00a0prototype-based\u00a0language, which means that inheritance \u2014 the mechanism that allows one object to access properties","breadcrumb":{"@id":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/#primaryimage","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/10\/2-6.png","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/10\/2-6.png","width":1080,"height":1080,"caption":"javascript prototype and inheritance"},{"@type":"BreadcrumbList","@id":"https:\/\/codeflarelimited.com\/blog\/javascript-prototypes-and-inheritance\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codeflarelimited.com\/blog\/"},{"@type":"ListItem","position":2,"name":"javascript","item":"https:\/\/codeflarelimited.com\/blog\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript Prototypes And Inheritance"}]},{"@type":"WebSite","@id":"https:\/\/codeflarelimited.com\/blog\/#website","url":"https:\/\/codeflarelimited.com\/blog\/","name":"","description":"Sustainable solutions","publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codeflarelimited.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codeflarelimited.com\/blog\/#organization","name":"Codeflare Limited","url":"https:\/\/codeflarelimited.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","width":1040,"height":263,"caption":"Codeflare Limited"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a","name":"codeflare","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","caption":"codeflare"},"description":"Latest tech news and coding tips.","sameAs":["https:\/\/codeflarelimited.com\/blog","https:\/\/facebook.com\/codeflretech","https:\/\/instagram.com\/codeflaretech","https:\/\/x.com\/codeflaretech","https:\/\/www.youtube.com\/channel\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1"],"url":"https:\/\/codeflarelimited.com\/blog\/author\/watcher\/"}]}},"jetpack_featured_media_url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/10\/2-6.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/3090","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/comments?post=3090"}],"version-history":[{"count":1,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/3090\/revisions"}],"predecessor-version":[{"id":3092,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/3090\/revisions\/3092"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media\/3091"}],"wp:attachment":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media?parent=3090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/categories?post=3090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/tags?post=3090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}