Cannot assign to read only property 'name' of object '[object Object]'

后端 未结 6 1522
攒了一身酷
攒了一身酷 2021-02-04 03:19

The following code will throw an error only for the name property. It could be fixed by specifying name property as writable in Object.create

6条回答
  •  野的像风
    2021-02-04 03:55

    Used ES7+ or TypeScript spread operator feature to overcome this

    obj = { ...obj, name: { first: 'hey', last: 'there'} }
    

提交回复
热议问题