View Full Version : SCRIPT438: Object doesn't support property or method 'keys' for IE

12-27-2011, 06:29 AM
I found strange for the following code:

var allextRules = Ext.util.CSS.getRules();

Object.keys(allextRules).forEach(function(key) {
var keyname = key;
if(keyname.indexOf("js") != -1){
console.log(keyname + " Removed");

When the above work is tested in other browser (say - Google Chrome), there is no error. However, when tested in IE 9, there is error as follows:

SCRIPT438: Object doesn't support property or method 'keys'

According to this article (https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys), the Object.keys is supported by IE.

Have I miss out something?

12-27-2011, 09:19 AM
Why don't you test the compatibility code there?

if(!Object.keys) Object.keys = function(o){
if (o !== Object(o))
throw new TypeError('Object.keys called on non-object');
var ret=[],p;
for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p);
return ret;