Browser polyfill for the ES5 `Object.keys()` method, that returns an array of a given object's own enumerable properties.
if (!Object.keys) {
/**
* Shim for `Object.keys`
*
* http://tokenposts.blogspot.com.au/2012/04/javascript-objectkeys-browser.html
*
* @param {Object} obj The target object.
* @return {Array} An array of keys.
*/
Object.keys = function(obj) {
if (obj !== Object(obj)) {
throw new TypeError('Object.keys cannnot be called on a non-object');
}
var keys = [],
prop;
for (prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
keys.push(prop);
}
}
return keys;
};
}