{"id":4354,"date":"2020-06-26T02:40:11","date_gmt":"2020-06-25T23:40:11","guid":{"rendered":"https:\/\/elzero.org\/?p=4354"},"modified":"2020-06-26T02:40:11","modified_gmt":"2020-06-25T23:40:11","slug":"js-oop-prototype-part-4-prototype-chain","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/js-oop-prototype-part-4-prototype-chain\/","title":{"rendered":"Prototype Part 4 Prototype Chain"},"content":{"rendered":"<h3>\u0627\u0644 Code \u0627\u0644\u0645\u0648\u062c\u0648\u062f \u0641\u064a \u0627\u0644\u062f\u0631\u0633<\/h3>\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\n\/*\r\n  Prototype\r\n  [1] Every Object Has A Prototype\r\n  [2] Prototype Chain Ends With Object.prototype\r\n  [2] In Javascript Function Is Object\r\n*\/\r\n\r\nfunction User(name) {\r\n  \/*\r\n    [1] Create Empty Object\r\n    [2] Assign The New Object To this Context\r\n    [3] New Object Created Prototype = Function Prototype\r\n    this = {};\r\n    this.__proto__ = User.__proto__\r\n  *\/\r\n  this.name = name;\r\n  \/* \r\n    [4] Return The New Object\r\n    return this\r\n  *\/\r\n\r\n  \/\/ if (!(this instanceof User)) {\r\n  \/\/   \/\/ throw new Error(\"Must Be Called With New Keyword\");\r\n  \/\/   console.log(\"Error\");\r\n  \/\/ }\r\n\r\n  \/\/ ES6\r\n  if (!new.target) {\r\n    \/\/ throw new Error(\"Must Be Called With New Keyword\");\r\n    console.log(\"Error\");\r\n  }\r\n}\r\n\r\nlet user1 = new User(\"Osama\");\r\nlet user2 = new User(\"Ahmed\");\r\nconsole.log(User.prototype);\r\nconsole.log(user1);\r\n\r\nlet myArray = [1, 2, 3, 4];\r\n\r\n<\/script>\r\n<hr>\r\n<h3>\u0645\u0644\u0627\u062d\u0638\u0627\u062a \u0627\u0644\u062f\u0631\u0633<\/h3>\r\n\u0644\u0627 \u062a\u0648\u062c\u062f \u0645\u0644\u0627\u062d\u0638\u0627\u062a \u062d\u0627\u0644\u064a\u0627","protected":false},"excerpt":{"rendered":"<p>\u0627\u0644 Code \u0627\u0644\u0645\u0648\u062c\u0648\u062f \u0641\u064a \u0627\u0644\u062f\u0631\u0633 \u0645\u0644\u0627\u062d\u0638\u0627\u062a \u0627\u0644\u062f\u0631\u0633 \u0644\u0627 \u062a\u0648\u062c\u062f \u0645\u0644\u0627\u062d\u0638\u0627\u062a \u062d\u0627\u0644\u064a\u0627<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[436],"tags":[],"class_list":["post-4354","post","type-post","status-publish","format-standard","hentry","category-javascript-oop"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/4354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=4354"}],"version-history":[{"count":1,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/4354\/revisions"}],"predecessor-version":[{"id":4355,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/4354\/revisions\/4355"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=4354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=4354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=4354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}