Add multiple attributes to an existing js object

前端 未结 6 1032
不知归路
不知归路 2020-12-31 01:50

I want to add multiple attributes to an existing object with existing attributes. Is there a more concise way than one line per new attribute?

myObject.name         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-31 01:58

    Use jQuery library

    jQuery.extend(myObject, { name : 'don', gender : 'male' });
    

提交回复
热议问题