Example 1 — Not own properties
map is inherited.
JavaScript
console.log([].hasOwnProperty("map"));How It Works
- Inherited from the prototype.
Array.prototype is the object that holds shared array methods like push, map, and filter. Instances inherit them through the prototype chain.
console.log(typeof Array.prototype.map);
console.log([].map === Array.prototype.map);
console.log(Object.getPrototypeOf([]) === Array.prototype);map is inherited.
console.log([].hasOwnProperty("map"));CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful