Object vs. Prototype Properties in Javascript
· ☕ 2 min read
Check if a given object has a specified property. You can either use non-enumerable props or hasOwnProperty.
Consider the below code -
1 2 3 4 Object.prototype.awesomeness = 42; const earth = {}; console.log(earth["awesomeness"]); // 42 We have defined a prototype that gets attached to any object. Therefore the prop defined by prototype is attached to the object as well.