1

I am new to prototypes. I have defined an object literal like this

const obj = {
    name: 'Prashant',
    sayHI(){
        console.log("Hi, I am Prashant");
    }
}

console.log(obj);

Result in console here!!!:
Result in console here!!!

After console logging the object I am getting a property ([[Prototype]]: Object) whose __proto __ property is also referencing to object.prototype.

If obj is an object why it's prototype is also pointing to object.prototype instead of pointing to null and why they both have the same functions?

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Prashant
  • 48
  • 4
  • "The __proto__ property of Object.prototype is an accessor property (a getter function and a setter function) that exposes the internal [[Prototype]] (either an object or null ) of the object through which it is accessed." https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto – GrafiCode May 19 '22 at 08:51
  • Also: https://stackoverflow.com/q/9959727/5768908 – Gerardo Furtado May 19 '22 at 08:52

0 Answers0