首页 > 其他 > 详细

Object.fromEntries

时间:2020-01-24 16:04:16      阅读:72      评论:0      收藏:0      [点我收藏+]
//数组转换成对象
const arr = [[‘foo‘, 1],[‘bar‘, 2]]
const obj = Object.fromEntries(arr)
console.log(obj.bar)

//找出key的长度为3的值
const obj = {
  abc: 1,
  def: 2,
  ghewe: 3
}

let res = Object.fromEntries(
  Object.entries(obj).filter(([key, val]) => key.length === 3)
)
console.log(res)

 

Object.fromEntries

原文:https://www.cnblogs.com/qjb2404/p/12232278.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!