json对象的key有空格的处理方式:
let dor = {
"role name": "admin",
"id": 5,
"description": "create by zhoukf",
"datas": [{ "module": "Package Info", "ids": [1, 2] },
{ "module":"Vehicle(Bench) Info", "ids": [3, 4, 5, 6] }]
}
//
dor.id
const {id} = dor
// dor.role name // 报错
// const {role name} = dor // 报错
dor['role name']
箭头函数的return省不省:
// 省return
const arr = [1, 2, 3, 4, 4]
console.log(arr.map(item => item));
let a = arr.map((item, index) =>
// ({ [item]: index }),
({
'a': item,
'b': index,
item: index
})
);
console.log(a);
// 不省 return
let datas = dor.datas.map((item) => {
console.log(item);
return { [item.module]: item.ids }
}
)
console.log(datas,...datas)