javascript Object assign 方法赋值

  • 初始化
    var object={ "a": 1, "b": 2 }
    var object_assigned = {"a": 10, "b": 20}
    
  • 属性更改
    •   Object.assign(object_assigned, map_object)
        console.log(object_assigned)
      

      --->

      {
        a:1,
        b:2
      }
      

    •   Object.assign(object_assigned, {"a": 15, "c": 15})
        console.log(object_assigned)
      

      --->

      {
        a:15,
        b:2,
        c:15
      }
      
posted @ 2022-02-17 15:29  cc-31415926  阅读(98)  评论(0编辑  收藏  举报