Today I received an error using Object.keys because I accidentally passed a value without an object:
var filter = true; var filterKeys = Object.keys(filter);
This works fine in Chrome, but in IE 11 I got an exception and after debugging I found that Object.keys throws an Object.keys exception in IE 11 : the argument is not an object .
IE11 behaved better in this situation, because true is really invalid, but chrome returned an empty array. Object.keys is the standard ECMAScript, and if you look at http://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.14 , it says:
- If type (O) is not an object, throw a TypeError exception.
Does anyone know why the implementation of Google Chrome behaves differently than in the ECMAScript specification standard, because I always thought that all modern browsers should implement ECMAScript in order to behave the same way.
javascript google-chrome internet-explorer
Andzej maciusovic
source share