for compatiblity. 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; } or use: function numKeys (o) { var i=0; for (p in o) if (Object.prototype.hasOwnProperty.call (o,p)) { i++}; return i; }

6262

The JavaScript keys () method is a build-in method in javascript, which returns an array iterator object that contains the keys for every index in an array. The JavaScript keys () method does not ignore the hole present in an array if we need to ignore holes we can use the object.keys () method.

var res = [];. for (var i in o) {.