?
This document uses PHP Chinese website manual Release
將源對象的可枚舉字符串鍵屬性分配給目標(biāo)對象。源對象從左到右應(yīng)用。后續(xù)來源將覆蓋之前來源的屬性分配。
注意: 此方法變異object
并且松散地基于Object.assign
。
0.10.0
object
(對象):目標(biāo)對象。
[sources]
(...對象):源對象。
(對象):返回object
。
function Foo() { this.a = 1;} function Bar() { this.c = 3;} Foo.prototype.b = 2; Bar.prototype.d = 4; _.assign({ 'a': 0 }, new Foo, new Bar); // => { 'a': 1, 'c': 3 }
這個方法就像_.assign
它遍歷自己的和繼承的源屬性。
注意:此方法發(fā)生變化object
。
4.0.0
_.extend
object
(對象):目標(biāo)對象。
[sources]
(...對象):源對象。
(對象):返回object
。
function Foo() { this.a = 1;} function Bar() { this.c = 3;} Foo.prototype.b = 2; Bar.prototype.d = 4; _.assignIn({ 'a': 0 }, new Foo, new Bar); // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
這種方法就像_.assignIn
是接受customizer
調(diào)用它來產(chǎn)生分配的值。如果customizer
返回undefined
,則賦值由該方法處理。該customizer
被調(diào)用,五個參數(shù):(objValue,srcValue,鍵,對象,源)。
注意:此方法發(fā)生變化object
。
版本
4.0.0
_.extendWith
object
(對象):目標(biāo)對象。
sources
(...對象):源對象。
[customizer]
(功能):自定義指定值的功能。
(對象):返回object
。
function customizer(objValue, srcValue) { return _.isUndefined(objValue) ? srcValue : objValue;} var defaults = _.partialRight(_.assignInWith, customizer); defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); // => { 'a': 1, 'b': 2 }
這種方法就像_.assign
是接受customizer
調(diào)用它來產(chǎn)生分配的值。如果customizer
返回undefined
,則賦值由該方法處理。該customizer
被調(diào)用,五個參數(shù):(objValue,srcValue,鍵,對象,源)。
注意:此方法發(fā)生變化object
。
4.0.0
object
(對象):目標(biāo)對象。
sources
(...對象):源對象。
[customizer]
(功能):自定義指定值的功能。
(對象):返回object
。
function customizer(objValue, srcValue) { return _.isUndefined(objValue) ? srcValue : objValue;} var defaults = _.partialRight(_.assignWith, customizer); defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); // => { 'a': 1, 'b': 2 }
創(chuàng)建對應(yīng)于paths
的值的數(shù)組object
。
版本
1.0.0
object
(Object):迭代的對象。
[paths]
(...(string | string [])):要選擇的屬性路徑。
(數(shù)組):返回采集的值。
var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; _.at(object, ['a[0].b.c', 'a[1]']);// => [3, 4]
創(chuàng)建一個從prototype
對象繼承的對象。如果properties
給定一個對象,則將其自己的可枚舉字符串鍵控屬性分配給創(chuàng)建的對象。
版本
2.3.0
prototype
(Object):要繼承的對象。
[properties]
(對象):要分配給對象的屬性。
(Object):返回新的對象。
function Shape() { this.x = 0; this.y = 0;} function Circle() { Shape.call(this);} Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle}); var circle = new Circle;circle instanceof Circle;// => true circle instanceof Shape;// => true
將源對象的自身和繼承的可枚舉字符串鍵控屬性分配給所有要解析為的目標(biāo)屬性的目標(biāo)對象undefined
。源對象從左到右應(yīng)用。一旦設(shè)置了屬性,相同屬性的其他值將被忽略。
注意:此方法發(fā)生變化object
。
0.1.0
object
(對象):目標(biāo)對象。
[sources]
(...對象):源對象。
(對象):返回object
。
_.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); // => { 'a': 1, 'b': 2 }
此方法與_.defaults
遞歸分配默認屬性不同。
注意:此方法發(fā)生變化object
。
3.10.0
object
(對象):目標(biāo)對象。
[sources]
(...對象):源對象。
(對象):返回object
。
_.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); // => { 'a': { 'b': 2, 'c': 3 } }
這個方法就像_.find
是它返回第一個元素的鍵 predicate
返回truthy而不是元素本身。
1.1.0
object
(對象):要檢查的對象。
[predicate=_.identity]
(Function):每次迭代調(diào)用的函數(shù)。
(*):返回匹配元素的關(guān)鍵字else undefined
。
var users = { 'barney': { 'age': 36, 'active': true }, 'fred': { 'age': 40, 'active': false }, 'pebbles': { 'age': 1, 'active': true }}; _.findKey(users, function(o) { return o.age < 40; }); // => 'barney' (iteration order is not guaranteed) // The `_.matches` iteratee shorthand. _.findKey(users, { 'age': 1, 'active': true }); // => 'pebbles' // The `_.matchesProperty` iteratee shorthand. _.findKey(users, ['active', false]); // => 'fred' // The `_.property` iteratee shorthand. _.findKey(users, 'active'); // => 'barney'
這個方法就像_.findKey
是它以相反的順序遍歷一個集合的元素。
2.0.0
object
(對象):要檢查的對象。
[predicate=_.identity]
(Function):每次迭代調(diào)用的函數(shù)。
(*):返回匹配元素的關(guān)鍵字else undefined
。
var users = { 'barney': { 'age': 36, 'active': true }, 'fred': { 'age': 40, 'active': false }, 'pebbles': { 'age': 1, 'active': true }}; _.findLastKey(users, function(o) { return o.age < 40; }); // => returns 'pebbles' assuming ` _.findKey` returns 'barney' // The `_.matches` iteratee shorthand. _.findLastKey(users, { 'age': 36, 'active': true }); // => 'barney' // The `_.matchesProperty` iteratee shorthand. _.findLastKey(users, ['active', false]); // => 'fred' // The `_.property` iteratee shorthand. _.findLastKey(users, 'active'); // => 'pebbles'
迭代對象的自己和繼承的可枚舉字符串鍵控屬性,并iteratee
為每個屬性調(diào)用。迭代器被調(diào)用三個參數(shù):(value,key,object)。迭代器函數(shù)可以通過顯式返回提前退出迭代false
。
0.3.0
object
(Object):迭代的對象。
[iteratee=_.identity]
(Function):每次迭代調(diào)用的函數(shù)。
(對象):返回object
。
function Foo() { this.a = 1; this.b = 2;} Foo.prototype.c = 3; _.forIn(new Foo, function(value, key) { console.log(key);}); // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
這個方法就像_.forIn
是它object
以相反的順序迭代屬性 。
2.0.0
object
(Object):迭代的對象。
[iteratee=_.identity]
(Function):每次迭代調(diào)用的函數(shù)。
(Object): Returns object
.
function Foo() { this.a = 1; this.b = 2;} Foo.prototype.c = 3; _.forInRight(new Foo, function(value, key) { console.log(key);}); // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
迭代對象的自身枚舉字符串鍵控屬性并iteratee
為每個屬性調(diào)用。迭代器被調(diào)用三個參數(shù):(value,key,object)。迭代器函數(shù)可以通過顯式返回提前退出迭代false
。
0.3.0
object
(Object):迭代的對象。
[iteratee=_.identity]
(Function):每次迭代調(diào)用的函數(shù)。
(對象):返回object
。
function Foo() { this.a = 1; this.b = 2;} Foo.prototype.c = 3; _.forOwn(new Foo, function(value, key) { console.log(key);});// => Logs 'a' then 'b' (iteration order is not guaranteed).
這個方法就像_.forOwn
是它object
以相反的順序迭代屬性。
2.0.0
object
(Object):迭代的對象。
[iteratee=_.identity]
(Function):每次迭代調(diào)用的函數(shù)。
(對象):返回object
。
function Foo() { this.a = 1; this.b = 2;} Foo.prototype.c = 3; _.forOwnRight(new Foo, function(value, key) { console.log(key);});// => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
從自己的可枚舉屬性中創(chuàng)建一個函數(shù)屬性名稱數(shù)組object
。
0.1.0
object
(對象):要檢查的對象。
(數(shù)組):返回函數(shù)名稱。
function Foo() { this.a = _.constant('a'); this.b = _.constant('b');} Foo.prototype.c = _.constant('c'); _.functions(new Foo);// => ['a', 'b']
從自己的繼承的可枚舉屬性創(chuàng)建一個函數(shù)屬性名稱數(shù)組object
。
4.0.0
object
(對象):要檢查的對象。
(數(shù)組):返回函數(shù)名稱。
function Foo() { this.a = _.constant('a'); this.b = _.constant('b');} Foo.prototype.c = _.constant('c'); _.functionsIn(new Foo);// => ['a', 'b', 'c']
獲取path
of 的值object
。如果解決的值是undefined
, defaultValue
則返回原位。
3.7.0
object
(Object):要查詢的對象。
path
(Array | string):要獲取的屬性的路徑。
[defaultValue]
(*):返回undefined
解析值的值。
(*):返回已解析的值。
var object = { 'a': [{ 'b': { 'c': 3 } }] }; _.get(object, 'a[0].b.c');// => 3 _.get(object, ['a', '0', 'b', 'c']);// => 3 _.get(object, 'a.b.c', 'default');// => 'default'
檢查是否path
是否含有object
。
版本
0.1.0
object
(Object):要查詢的對象。
path
(數(shù)組|字符串):要檢查的路徑。
(boolean):返回true
是否path
存在,否則false
。
var object = { 'a': { 'b': 2 } };var other = _.create({ 'a': _.create({ 'b': 2 }) }); _.has(object, 'a');// => true _.has(object, 'a.b');// => true _.has(object, ['a', 'b']);// => true _.has(other, 'a');// => false
檢查是否path
是直接或繼承的屬性object
。
4.0.0
object
(Object):要查詢的對象。
path
(數(shù)組|字符串):要檢查的路徑。
(boolean):返回true
是否path
存在,否則false
。
var object = _.create({ 'a': _.create({ 'b': 2 }) }); _.hasIn(object, 'a');// => true _.hasIn(object, 'a.b');// => true _.hasIn(object, ['a', 'b']);// => true _.hasIn(object, 'b');// => false
創(chuàng)建一個由倒置鍵和值組成的對象object
。如果object
包含重復(fù)值,則后續(xù)值將覆蓋以前值的屬性分配。
0.7.0
object
(對象):要反轉(zhuǎn)的對象。
(Object):返回新的倒置對象。
var object = { 'a': 1, 'b': 2, 'c': 1 }; _.invert(object);// => { '1': 'c', '2': 'b' }
這種方法是等_.invert
不同之處在于,從運行中的每個元素的結(jié)果所產(chǎn)生的反轉(zhuǎn)對象object
通iteratee
。每個反轉(zhuǎn)鍵的相應(yīng)反轉(zhuǎn)值是負責(zé)產(chǎn)生反轉(zhuǎn)值的鍵數(shù)組。迭代器被調(diào)用一個參數(shù):(value)。
4.1.0
object
(對象):要反轉(zhuǎn)的對象。
[iteratee=_.identity]
(Function):每個元素調(diào)用的迭代器。
(Object):返回新的倒置對象。
var object = { 'a': 1, 'b': 2, 'c': 1 }; _.invertBy(object);// => { '1': ['a', 'c'], '2': ['b'] } _.invertBy(object, function(value) { return 'group' + value;}); // => { 'group1': ['a', 'c'], 'group2': ['b'] }
調(diào)用path
of 處的方法object
。
4.0.0
object
(Object):要查詢的對象。
path
(Array | string):要調(diào)用的方法的路徑。
[args]
(... *):用來調(diào)用方法的參數(shù)。
(*): Returns the result of the invoked method.
var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; _.invoke(object, 'a[0].b.c.slice', 1, 3);// => [2, 3]
創(chuàng)建一個自己的可枚舉屬性名稱的數(shù)組object
。
注意: 非對象值被強制轉(zhuǎn)換為對象。有關(guān)更多詳細信息,請參閱ES規(guī)范。
0.1.0
object
(Object):要查詢的對象。
(Array):返回屬性名稱的數(shù)組。
function Foo() { this.a = 1; this.b = 2;} Foo.prototype.c = 3; _.keys(new Foo);// => ['a', 'b'] (iteration order is not guaranteed) _.keys('hi');// => ['0', '1']
創(chuàng)建一個自己的繼承的可枚舉屬性名稱的數(shù)組 object
。
注意:非對象值被強制轉(zhuǎn)換為對象。
3.0.0
object
(Object):要查詢的對象。
(Array):返回屬性名稱的數(shù)組。
function Foo() { this.a = 1; this.b = 2;} Foo.prototype.c = 3; _.keysIn(new Foo);// => ['a', 'b', 'c'] (iteration order is not guaranteed)
與之相反_.mapValues
; 此方法創(chuàng)建一個具有與object
通過運行object
thru的每個自己的可枚舉字符串鍵控屬性生成的鍵值 相同的值的對象iteratee
。迭代器被調(diào)用三個參數(shù):(value,key,object)。
3.8.0
object
(Object):迭代的對象。
[iteratee=_.identity]
(Function):每次迭代調(diào)用的函數(shù)。
(Object):返回新的映射對象。
_.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { return key + value;}); // => { 'a1': 1, 'b2': 2 }
使用與object
通過運行object
thru的每個自己的可枚舉字符串鍵控屬性所生成的相同的鍵和值創(chuàng)建一個對象iteratee
。迭代器被調(diào)用三個參數(shù):
(value, key, object).
2.4.0
object
(Object):迭代的對象。
[iteratee=_.identity]
(Function):每次迭代調(diào)用的函數(shù)。
(Object):返回新的映射對象。
var users = { 'fred': { 'user': 'fred', 'age': 40 }, 'pebbles': { 'user': 'pebbles', 'age': 1 }}; _.mapValues(users, function(o) { return o.age; }); // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) // The `_.property` iteratee shorthand._.mapValues(users, 'age'); // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
這種方法就像_.assign
是遞歸地將源對象的自己和繼承的可枚舉字符串鍵控屬性合并到目標(biāo)對象中。undefined
如果目標(biāo)值存在,則解析為跳過的源屬性 。數(shù)組和簡單對象屬性是遞歸合并的。其他對象和值類型被賦值覆蓋。源對象從左到右應(yīng)用。后續(xù)來源將覆蓋之前來源的屬性分配。
注意:此方法發(fā)生變化object
。
0.5.0
object
(對象):目標(biāo)對象。
[sources]
(...對象):源對象。
(對象):返回object
。
var object = { 'a': [{ 'b': 2 }, { 'd': 4 }]}; var other = { 'a': [{ 'c': 3 }, { 'e': 5 }]}; _.merge(object, other);// => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
此方法類似,_.merge
只是它接受customizer
調(diào)用它來生成目標(biāo)和源屬性的合并值。如果customizer
返回 undefined
,則合并由該方法處理。該customizer
調(diào)用有六個參數(shù):
(objValue, srcValue, key, object, source, stack).
注意:此方法發(fā)生變化object
。
4.0.0
object
(對象):目標(biāo)對象。
sources
(...對象):源對象。
customizer
(功能):自定義指定值的功能。
(對象):返回object
。
function customizer(objValue, srcValue) { if (_.isArray(objValue)) { return objValue.concat(srcValue); }} var object = { 'a': [1], 'b': [2] }; var other = { 'a': [3], 'b': [4] }; _.mergeWith(object, other, customizer); // => { 'a': [1, 3], 'b': [2, 4] }
與之相反_.pick
; 此方法創(chuàng)建一個由自己和繼承的枚舉屬性路徑組成的對象,這些路徑object
不會被省略。
注意:這個方法比_.pick
慢
0.1.0
object
(對象):源對象。
[paths]
(...(string | string [])):要忽略的屬性路徑。
(Object):返回新的對象。
var object = { 'a': 1, 'b': '2', 'c': 3 }; _.omit(object, ['a', 'c']);// => { 'b': '2' }
與之相反_.pickBy
; 此方法創(chuàng)建自己組成的對象和繼承的枚舉字符串鍵的屬性object
是predicate
不返回truthy的。謂詞用兩個參數(shù)調(diào)用:(value,key)。
4.0.0
object
(對象):源對象。
[predicate=_.identity]
(Function):每個屬性調(diào)用的函數(shù)。
(Object):返回新的對象。
var object = { 'a': 1, 'b': '2', 'c': 3 }; _.omitBy(object, _.isNumber);// => { 'b': '2' }
創(chuàng)建一個由拾取object
屬性組成的對象。
0.1.0
object
(對象):源對象。
[paths]
(...(string | string [])):要選擇的屬性路徑。
(Object):返回新的對象。
var object = { 'a': 1, 'b': '2', 'c': 3 }; _.pick(object, ['a', 'c']);// => { 'a': 1, 'c': 3 }
創(chuàng)建一個由object
屬性predicate
返回truthy 組成的對象。謂詞用兩個參數(shù)調(diào)用:(value,key)。
4.0.0
object
(對象):源對象。
[predicate=_.identity]
(Function):每個屬性調(diào)用的函數(shù)。
(Object):返回新的對象。
var object = { 'a': 1, 'b': '2', 'c': 3 }; _.pickBy(object, _.isNumber);// => { 'a': 1, 'c': 3 }
這種方法就像是_.get
,如果解析的值是一個函數(shù),它的this
父對象的綁定將被調(diào)用,并返回結(jié)果。
0.1.0
object
(Object):要查詢的對象。
path
(Array | string):要解析的屬性的路徑。
[defaultValue]
(*):返回undefined
解析值的值。
(*):返回已解析的值。
var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; _.result(object, 'a[0].b.c1');// => 3 _.result(object, 'a[0].b.c2');// => 4 _.result(object, 'a[0].b.c3', 'default');// => 'default' _.result(object, 'a[0].b.c3', _.constant('default'));// => 'default'
設(shè)置在價值path
的object
。如果一部分path
不存在,則創(chuàng)建它。為缺少索引屬性創(chuàng)建數(shù)組,而為所有其他缺少的屬性創(chuàng)建對象。使用_.setWith
自定義path
創(chuàng)建。
注意:此方法發(fā)生變化object
。
3.7.0
object
(對象):要修改的對象。
path
(Array | string):要設(shè)置的屬性的路徑。
value
(*):要設(shè)置的值。
(對象):返回object
。
var object = { 'a': [{ 'b': { 'c': 3 } }] }; _.set(object, 'a[0].b.c', 4); console.log(object.a[0].b.c);// => 4 _.set(object, ['x', '0', 'y', 'z'], 5); console.log(object.x[0].y.z);// => 5
這個方法類似于_.set
它接受customizer
被調(diào)用來產(chǎn)生對象的方法path
。如果customizer
返回undefined
路徑創(chuàng)建是由方法處理的。該customizer
調(diào)用有三個參數(shù):(nsValue,key,nsObject)。
注意:此方法發(fā)生變化object
。
4.0.0
object
(對象):要修改的對象。
path
(Array | string):要設(shè)置的屬性的路徑。
value
(*):要設(shè)置的值。
[customizer]
(功能):自定義指定值的功能。
(對象):返回object
。
var object = {}; _.setWith(object, '[0][1]', 'a', Object); // => { '0': { '1': 'a' } }
創(chuàng)建一個可object
由其使用的自己可枚舉的字符串鍵控值對的數(shù)組_.fromPairs
。如果object
是地圖或集合,則返回其條目。
4.0.0
_.entries
object
(Object):要查詢的對象。
(數(shù)組):返回鍵值對。
function Foo() { this.a = 1; this.b = 2;} Foo.prototype.c = 3; _.toPairs(new Foo); // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
創(chuàng)建一個自己的和繼承的可枚舉的字符串鍵值對的數(shù)組,供object
其使用_.fromPairs
。如果object
是地圖或集合,則返回其條目。
4.0.0
_.entriesIn
object
(Object):要查詢的對象。
(數(shù)組):返回鍵值對。
function Foo() { this.a = 1; this.b = 2;} Foo.prototype.c = 3; _.toPairsIn(new Foo);// => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
替代方案_.reduce
; 這個方法轉(zhuǎn)換object
為一個新的 accumulator
對象,這個對象是通過運行每個自己的可枚舉字符串鍵控屬性的結(jié)果iteratee
,每個調(diào)用都可能會突變accumulator
對象。如果accumulator
沒有提供,[[Prototype]]
將使用一個相同的新對象。迭代器被調(diào)用四個參數(shù):( 累加器,值,鍵,對象)。迭代器函數(shù)可以通過顯式返回提前退出迭代false
。
1.3.0
object
(Object):迭代的對象。
[iteratee=_.identity]
(Function):每次迭代調(diào)用的函數(shù)。
[accumulator]
(*):自定義累加器值。
(*):返回累計值。
_.transform([2, 3, 4], function(result, n) { result.push(n *= n); return n % 2 == 0;}, []);// => [4, 9] _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { (result[value] || (result[value] = [])).push(key);}, {}); // => { '1': ['a', 'c'], '2': ['b'] }
移除path
of 處的財產(chǎn)object
。
注意:此方法發(fā)生變化 object
。
4.0.0
object
(對象):要修改的對象。
path
(數(shù)組|字符串):要設(shè)置的屬性的路徑。
(boolean):返回true
屬性是否被刪除,否則false
。
var object = { 'a': [{ 'b': { 'c': 7 } }] }; _.unset(object, 'a[0].b.c');// => true console.log(object);// => { 'a': [{ 'b': {} }] }; _.unset(object, ['a', '0', 'b', 'c']);// => true console.log(object);// => { 'a': [{ 'b': {} }] };
這種方法就像_.set
接受updater
產(chǎn)生要設(shè)置的值一樣。使用_.updateWith
自定義path
創(chuàng)建。該 updater
被調(diào)用,一個參數(shù):(值)。
注意:此方法發(fā)生變化object
。
4.6.0
object
(對象):要修改的對象。
path
(Array | string):要設(shè)置的屬性的路徑。
updater
(功能):產(chǎn)生更新值的功能。
(對象):返回object
。
var object = { 'a': [{ 'b': { 'c': 3 } }] }; _.update(object, 'a[0].b.c', function(n) { return n * n; });console.log(object.a[0].b.c);// => 9 _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });console.log(object.x[0].y.z);// => 0
這個方法類似于_.update
它接受customizer
被調(diào)用來產(chǎn)生對象的方法path
。如果customizer
返回undefined
路徑創(chuàng)建是由方法處理的。該customizer
調(diào)用有三個參數(shù):(nsValue,key,nsObject)。
注意:此方法發(fā)生變化object
。
4.6.0
object
(對象):要修改的對象。
path
(Array | string):要設(shè)置的屬性的路徑。
updater
(功能):產(chǎn)生更新值的功能。
[customizer]
(功能):自定義指定值的功能。
(對象):返回object
。
var object = {}; _.updateWith(object, '[0][1]', _.constant('a'), Object);// => { '0': { '1': 'a' } }
創(chuàng)建一個自己的可枚舉字符串鍵控屬性值的數(shù)組object
。
注意:非對象值被強制轉(zhuǎn)換為對象。
0.1.0
object
(Object):要查詢的對象。
(Array):返回屬性值的數(shù)組。
function Foo() { this.a = 1; this.b = 2;} Foo.prototype.c = 3; _.values(new Foo);// => [1, 2] (iteration order is not guaranteed) _.values('hi');// => ['h', 'i']
創(chuàng)建自己的和繼承的可枚舉字符串鍵控屬性值的數(shù)組 object
。
注意:非對象值被強制轉(zhuǎn)換為對象。
3.0.0
object
(Object):要查詢的對象。
(Array):返回屬性值的數(shù)組。
function Foo() { this.a = 1; this.b = 2;} Foo.prototype.c = 3; _.valuesIn(new Foo);// => [1, 2, 3] (iteration order is not guaranteed)