How to set specific property value of all objects in a javascript object array (lodash)

后端 未结 3 1523
难免孤独
难免孤独 2020-12-16 15:58

I have following object array:

var arr = [
  {
    id    : \"a1\",
    guid  : \"sdfsfd\",
    ...
    value : \"abc\",
    status: \"active\"
  },
  {
             


        
3条回答
  •  孤街浪徒
    2020-12-16 16:25

    A way simpler and and cleaner way !!!!!

    If you want to use func programming in a proper manner

      myArray = myArray.map(arrayElem => {
        arrayElem.property = newValue
        return arrayElem
      })
    

提交回复
热议问题