mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
committed by
John-David Dalton
parent
151e316263
commit
c33df3147f
32
keysIn.js
Normal file
32
keysIn.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Creates an array of the own and inherited enumerable property names of `object`.
|
||||
*
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property names.
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
* this.a = 1;
|
||||
* this.b = 2;
|
||||
* }
|
||||
*
|
||||
* Foo.prototype.c = 3;
|
||||
*
|
||||
* _.keysIn(new Foo);
|
||||
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
|
||||
*/
|
||||
function keysIn(object) {
|
||||
const result = []
|
||||
for (key in object) {
|
||||
result.push(key)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export default keysIn
|
||||
|
||||
Reference in New Issue
Block a user