javascript set all values in array of object

后端 未结 4 2015
时光说笑
时光说笑 2021-01-03 23:50

Two part question about similar problems. I\'ve got 2 different arrays,

array 1:

 array1 = [{
     name : \"users\",
     checked :          


        
4条回答
  •  伪装坚强ぢ
    2021-01-04 00:49

    Even though this is not a lot of code i'm just curious if there is a way to do this without iterating over every object in the array. (not sure if this is even possible or whether this makes any difference whatsoever, so if please correct me if i am wrong about any of this).

    Is it possible to simply set all the values to true or false at once (again i can use a for loop, but would prefer not to)

    No ! You can't visit all towns without visiting each of them. There are shortcuts with jQuery like $.each and lodash like _.map but it's just a function that's doing what you would do with the for loop.

提交回复
热议问题