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');
7 /** Used for native method references. */
8 var objectProto = Object.prototype;
10 /** Used to check objects for own properties. */
11 var hasOwnProperty = objectProto.hasOwnProperty;
14 * Creates an array of the own and inherited enumerable property names of `object`.
16 * **Note:** Non-object values are coerced to objects.
21 * @param {Object} object The object to query.
22 * @returns {Array} Returns the array of property names.
30 * Foo.prototype.c = 3;
33 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
35 function keysIn(object) {
39 if (!isObject(object)) {
40 object = Object(object);
42 var length = object.length;
43 length = (length && isLength(length) &&
44 (isArray(object) || isArguments(object)) && length) || 0;
46 var Ctor = object.constructor,
48 isProto = typeof Ctor == 'function' && Ctor.prototype === object,
49 result = Array(length),
50 skipIndexes = length > 0;
52 while (++index < length) {
53 result[index] = (index + '');
55 for (var key in object) {
56 if (!(skipIndexes && isIndex(key, length)) &&
57 !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
64 module.exports = keysIn;