阅读(2983) (0)

Lodash _.entries->toPairs

2021-09-23 09:28:22 更新

_.toPairs(object)

创建一个object对象自身可枚举属性的键值对数组。这个数组可以通过_.fromPairs撤回。如果object 是 map 或 set,返回其条目。

添加版本

4.0.0

Aliases

_.entries

参数

  1. object (Object): 要检索的对象。

返回

(Array): 返回键值对的数组。

例子

function Foo() {  this.a = 1;  this.b = 2;} Foo.prototype.c = 3;
 _.toPairs(new Foo);
// => [['a', 1], ['b', 2]] (iteration order is not guaranteed)