//DO THIS IN YOUR BROWSER'S CONSOLE
function Parent () {}
/* all functions be default get a public, nonenumerable property on them called PROTOTYPE,
which is an object that possess a constructor key/property that is a reference to the
function itself, Parent in this case. This object is called the Parent's prototype. Recall
that nothing distinguishes a function that is used as a constructor from a function
that isn't: every function receives a prototype object. */
Parent.prototype; // {}
Parent.prototype.constructor; // Parent
var tom = new Parent()
//notice the DOUBLE underscores surrounding 'proto'
tom.__proto__ // logs Parent {}
/* notice that the object returned by the NEW operator possesses an inaccessible
__proto__ property that is a reference to the Parent constructor function's
prototype object. Each object created from calling new Parent() will end up
[[Prototype]]-linked to this prototype object. This link is nothing like the copy
operation that occurs in truly class-based languages like Java. */
tom.__proto__ === Parent.prototype // logs true
(new Parent).__proto__ === Parent.prototype //logs true
(new Parent).prototype // logs undefined
Last active
November 5, 2016 03:35
-
-
Save awilson28/a75f8ad1d8900ebe85b5 to your computer and use it in GitHub Desktop.
__proto__ (exercise to be completed in your browser's console)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This line returned the Parent Constructor Function
Maybe something to add (or change)