If the array is [true, false]
, and use .map()
to iterate it, the array itself is not changed
array.map(item => {
item = false
})
array is still [true, false]
But if the items of array are object, then the array would be changed
Initially, array is [{checked: true}, {checked: false}]
,
and iterate over the map,
array.map(item => {
item.checked = false
})
then array becomes [{checked: false}, {checked: false}]
can anyone tell me what the difference is between the two?