0

Here's the code:

var o ={};
console.log(Object.getPrototypeOf(o) == Object.prototype); // returns true as expected
console.log(Object.getPrototypeOf(Array) == Array.prototype); // returns false why?

Could someone please clarify the second result?

serg10
32.9k16 gold badges77 silver badges94 bronze badges
asked Nov 24, 2015 at 13:28
1
  • 1
    Because Array is not an instantiated instance of an Array Commented Nov 24, 2015 at 13:31

2 Answers 2

3

because Array is not an 'array' but the Prototype of Array but with this example :

var a = [];
console.log(Object.getPrototypeOf(a) == Array.prototype);

It works

answered Nov 24, 2015 at 13:31
Sign up to request clarification or add additional context in comments.

Comments

2

Try

var a=[];
console.log(Object.getPrototypeOf(a) == Array.prototype); 

You're using the Array type itself, instead of an instance of it.

answered Nov 24, 2015 at 13:30

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.