let obj = ["x","y","z"]; let objTmp = {}; Array.from(obj,(o)=>{ console.log(o+1); }); //x1,y1,z1
我想得到如下形式:
{x1:'', y1:"",z1:''}, 但不行,How?
let obj = ["x","y","z"]; let objTmp = {}; Array.from(obj,(o)=>{ Object.assign(objTmp, o+1); }); console.log( objTmp); //{"0":z, "1":1}
How?
```
let obj = ["x","y","z"];
let objTmp = {};
Array.from(obj,(o)=>{
objTmp[ o+"1" ] = "";
});
console.log( objTmp); // {x1:'', y1:"",z1:''}
```
Thank you. 对象的key是自增长的。