Lodash教程

Lodash fromPairs method

语法:

_.fromPairs(pairs)
The inverse of _.toPairs; this method returns an object composed from key-value pairs.

参数

pairs (Array) − The key-value pairs.

输出:

(Object) − Returns the new object.

实例:

var _ = require('lodash');
var list = [['One' , 1], ['Two', 2]];
var result = _.fromPairs(list)
console.log(result);
Save the above program in tester.js. Run the following command to execute this program.

命令:

\>node tester.js

输出:

{ One: 1, Two: 2 }
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4