keys.js 563 B

123456789101112131415161718
  1. define(['./isObject', './_setup', './_has', './_collectNonEnumProps'], function (isObject, _setup, _has, _collectNonEnumProps) {
  2. // Retrieve the names of an object's own properties.
  3. // Delegates to **ECMAScript 5**'s native `Object.keys`.
  4. function keys(obj) {
  5. if (!isObject(obj)) return [];
  6. if (_setup.nativeKeys) return _setup.nativeKeys(obj);
  7. var keys = [];
  8. for (var key in obj) if (_has(obj, key)) keys.push(key);
  9. // Ahem, IE < 9.
  10. if (_setup.hasEnumBug) _collectNonEnumProps(obj, keys);
  11. return keys;
  12. }
  13. return keys;
  14. });