1 var isArguments = require('../lang/isArguments'),
2 isArray = require('../lang/isArray'),
3 isIndex = require('../internal/isIndex'),
4 isLength = require('../internal/isLength'),
5 isObject = require('../lang/isObject'),
6 support = require('../support');
8 /** Used for native method references. */
9 var objectProto = Object.prototype;
11 /** Used to check objects for own properties. */
12 var hasOwnProperty = objectProto.hasOwnProperty;
15 * Creates an array of the own and inherited enumerable property names of `object`.
17 * **Note:** Non-object values are coerced to objects.
22 * @param {Object} object The object to query.
23 * @returns {Array} Returns the array of property names.
31 * Foo.prototype.c = 3;
34 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
36 function keysIn(object) {
40 if (!isObject(object)) {
41 object = Object(object);
43 var length = object.length;
44 length = (length && isLength(length) &&
45 (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0;
47 var Ctor = object.constructor,
49 isProto = typeof Ctor == 'function' && Ctor.prototype === object,
50 result = Array(length),
51 skipIndexes = length > 0;
53 while (++index < length) {
54 result[index] = (index + '');
56 for (var key in object) {
57 if (!(skipIndexes && isIndex(key, length)) &&
58 !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
65 module.exports = keysIn;