var pp = {'name': '1','work': 'teacher'}
var kk = [1,2]
var tt = []
for(let index = 0; index<kk.length;index++) {
tt.push({...pp})
}
for(let index = 0; index<kk.length;index++) {
tt[index].age = kk[index]
}
console.log(tt)
- tt(2) [{…}, {…}]
- 0:{name: "1", work: "teacher", age: 1}
- 1:{name: "1", work: "teacher", age: 2}
- length:2
- __proto__:Array(0)