How to avoid no-param-reassign when setting a property on a DOM object

前端 未结 11 674
无人共我
无人共我 2020-12-23 15:41

I have a method which\'s main purpose is to set a property on a DOM object

function (el) {
  el.expando = {};
}

I use AirBnB\'s code style

11条回答
  •  生来不讨喜
    2020-12-23 16:10

    If you want to change any value inside an object array, you can use

    array.forEach(a => ({ ...a, expando: {} }))
    

提交回复
热议问题