Value assigned to primitive will be lost

前端 未结 4 1479
感动是毒
感动是毒 2020-12-17 08:09

If I have an array of objects, and loop through them assigning a value to an attribute for each one, WebStorm warns me:

Values assigned to primitive w

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-17 08:31

    I just had the same issue.

    You can also ask WebStorm to disable inspection for the next line, but I decided to use a for of loop instead:

    for (person of people) {
        person.surname = 'Baz';
    }
    

    It actually made my code more readable as a result so I was happy.

提交回复
热议问题