0

I am using spread operator but my operation is not working correctly.

Here is my code and problem.

I declare a array of object.

let obj = [{id:1,name:"a"},{id:2,name:"b"}] then i am copying this to another variable. like this.

let newObj = {...obj}

now after copying what i am getting in newObj is object of array. means i can access newObj[0] or newObj[1] but i can not use for loop. I can not access newObj.length. how to fix this problem. can anybody please suggest that.

David
  • 4,266
  • 8
  • 34
  • 69

0 Answers0