Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Arvin iuunhao
Added: Jun 18, 2018 8:29 AM
Views: 11
Tags: js
根据键值对创建对象
  1. const objectFromPairs = arr => arr.reduce((a, v) => (a[v[0]] = v[1], a), {});
  2. // objectFromPairs([['a',1],['b',2]]) -> {a: 1, b: 2}