![]() Otherwise, JS checks if the prototype has the property. In a nutshell, when we try to access a property of an object, JS engine first checks if the object itself contains the property. Similarly, we can set the prototype of the object using _proto_ or tPrototypeOf: We can also find out what object is a prototype of a given object, by checking its _proto_ member or by calling Object.getPrototypeOf: In DevTools, we can easily check a list of properties of Object.prototype: If we don’t specify it, by default the prototype for an object is Object.prototype. Every object in JavaScript has a prototype (it can also be null). toString (along with some other default members) comes from the prototype. For example a call to obj.toString() would return "". But these are not the only properties we can access. This object has two properties: prop1 and prop2.
0 Comments
Leave a Reply. |