es6中对象转数组,转map

//对象转数组
let array = Object.keys(userPermission).map(key=> userPermission[key])

console.log(array)

userPermission是数据对象


//对象转map
objToStrMap(obj) {
let strMap = new Map();
for (let k of Object.keys(obj)) {
strMap.set(k, obj[k]);
}
return strMap;
}

//调用objToStrMap(obj)

posted on 2018-05-21 11:37  creatP  阅读(15363)  评论(1编辑  收藏  举报

导航