Object.keys behavior in chrome and IE 11

So does anyone know why Google Chrome implementation behaves not like in ECMAScript

It depends on which version of ECMAScript the browser has implemented.

In ECMA-262 ed 6 (the current standard) the first step is:

  1. Let obj be ToObject(O)

In ES5, the first step is:

  1. If the Type(O) is not Object, throw a TypeError exception.

So you can say that Chrome is consistent with ed 6 (it converts the primtive true to a Boolean object) and IE with ES5 (it throws a TypeError exception), and therefore both are compliant with different versions of the standard.


n this situation IE11 behaved better because value true is really invalid, but chrome returned empty array. Object.keys is ECMAScript standart and if you look at http://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.14 it says:

If the Type(O) is not Object, throw a TypeError exception.

ES5 is old

read the ES6 spec and you'll see Internet Exploder is the browser that is doing it the old way (Chrome and Firefox get it right)

http://www.ecma-international.org/ecma-262/6.0/#sec-object.keys

note: IE11 (or whatever the abomination is called in windows 10) does it the ES2015 way