Skip to content

Instantly share code, notes, and snippets.

@ivankisyov
Last active November 14, 2022 07:18
Show Gist options
  • Save ivankisyov/2d535063680ea70f9258eeab82a9e616 to your computer and use it in GitHub Desktop.
Save ivankisyov/2d535063680ea70f9258eeab82a9e616 to your computer and use it in GitHub Desktop.
What is dunder proto in JS

What is dunder proto in JS

dunder proto === __proto__

Every object in JS has this property.

It points back to the prototype object of the constructor function that created that object.

Only Object.prototype.__proto__ === null

How to retrive the value of __proto__ in production code

// you can use:
let testObj = {}
testObj.__proto__

// BUT a better approach would be:
Object.getPrototypeOf(testObj)

// result:
// Object.prototype

@policias
Copy link

Thanks man, I appreciate your short answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment