{"id":1235,"date":"2022-08-30T15:14:38","date_gmt":"2022-08-30T15:14:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/10\/do-arrays-have-no-prototype-by-default-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:14:38","modified_gmt":"2022-08-30T15:14:38","slug":"do-arrays-have-no-prototype-by-default-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/do-arrays-have-no-prototype-by-default-collection-of-common-programming-errors\/","title":{"rendered":"Do arrays have no prototype by default?-Collection of common programming errors"},"content":{"rendered":"<p><code>prototype<\/code> is a property of constructor functions, like <code>Array<\/code>. So <code>Array.prototype<\/code> exists, but not <code>[1, 2, 3].prototype<\/code>; <code>Array<\/code> is a constructor function, while <code>[1, 2, 3]<\/code> is an array.<\/p>\n<p>You are looking for <code>Object.getPrototypeOf([1, 2, 3])<\/code>.<\/p>\n<p><code>Object.getPrototypeOf<\/code> is an ECMAScript 5 method, and as such may not be present in all browsers. In which case, you can try accessing the <code>__proto__<\/code> property, i.e. <code>[1, 2, 3].__proto__<\/code>, which is an older, nonstandard thing that <code>Object.getPrototypeOf<\/code> is the new standard version of, or you can use an ES5 shim to ensure that wherever <code>__proto__<\/code> is supported, so is <code>Object.getPrototypeOf<\/code>.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-10 00:11:23. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>prototype is a property of constructor functions, like Array. So Array.prototype exists, but not [1, 2, 3].prototype; Array is a constructor function, while [1, 2, 3] is an array. You are looking for Object.getPrototypeOf([1, 2, 3]). Object.getPrototypeOf is an ECMAScript 5 method, and as such may not be present in all browsers. In which case, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1235","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1235"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1235\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}