JavaScript get prototype of object

I have:

var person = {
    kind: 'person'
};

// create new object specifying the prototype as person
var zack = Object.create( person );

console.log( Object.getPrototypeOf(zack) );

Output: Object {kind: "person"}

Why does it not output person?

Answers


When you get the prototype of an object by Object.getPrototypeOf(zack), it returns you the prototype object which is obviously your person object:

Your prototype object potentially has properties you defined for it (kind: "person"). Both person object you defined and prototype object returned by the function are equivalent.

Try checking the equality, you'll realize both are equal.

alert(person === Object.getPrototypeOf(zack)); // true

Need Your Help

How can you customize the numbers in an ordered list?

html css html-lists roman-numerals

How can I left-align the numbers in an ordered list?