4

String.prototype

String {}

Object.prototype

Object {}  

Boolean.prototype

Boolean {}

but Array.prototype outputs [], why not Array [] or something else? What happened?

4
  • 3
    I think this is due to the Inspector internal formatter. Commented Nov 27, 2013 at 11:06
  • Because that's just how the console represents arrays. It's probably different in some other browser's console. Commented Nov 27, 2013 at 11:07
  • @Florent do you have any article about it ? thanks Commented Nov 27, 2013 at 11:17
  • Which console are you using? Please add the respective browser-specific tag Commented Dec 1, 2013 at 22:00

1 Answer 1

1

I looked into the ECMA specs and V8 source code, but I couldn't get a concrete answer.

According to the ECMA-262 spec, every object must have algorithms for all of the essential internal methods, however, all objects do not necessarily use the same algorithms for those methods which means the output will be implementation specific at least in the case of [[GetPrototypeOf]].

Hence, if you try the same in different browsers, you'll notice that the output is slightly different in each.

Internet Explorer 11:

Array.prototype
[object Array]  []

String.prototype
[object String]  {length:0}

Object.prototype
[object Object]  {}

Boolean.prototype
[object Boolean]  {}

Firefox:

Array.prototype
[object Array]

String.prototype
[object String]

Object.prototype
[object Object]

Boolean.prototype
[object Boolean]

Chrome and Opera:

Array.prototype
[]

String.prototype
String {}

Object.prototype
Object {}

Boolean.prototype
Boolean {}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.