Javascript Object - prepend object to existing object - Stack Overflow

I have this javascript objects.<script language="javascript" type="textjavascript&

I have this javascript objects.

<script language="javascript" type="text/javascript">
var jsObject1 = {'Mr.':'1','Mrs.':'2','Ms.':'3'} 
</script>

I want to add this javascript object to the beginning of the jsObject variable:

<script language="javascript" type="text/javascript">
var jsObject2 = {'Dr.':'4','Sr.':'5','Jr.':'6'} 
</script>

Is there a javascript function, or perhaps jquery method for doing that?

I have this javascript objects.

<script language="javascript" type="text/javascript">
var jsObject1 = {'Mr.':'1','Mrs.':'2','Ms.':'3'} 
</script>

I want to add this javascript object to the beginning of the jsObject variable:

<script language="javascript" type="text/javascript">
var jsObject2 = {'Dr.':'4','Sr.':'5','Jr.':'6'} 
</script>

Is there a javascript function, or perhaps jquery method for doing that?

Share Improve this question asked Oct 1, 2013 at 4:56 coffeemonitorcoffeemonitor 13.2k35 gold badges105 silver badges153 bronze badges 2
  • 1 Possible duplicate : How can I merge properties of two JavaScript objects dynamically? – Pascalz Commented Oct 1, 2013 at 5:01
  • What does "beginning of the variable" mean? JavaScript objects are unordered. There is no beginning. – user2736012 Commented Oct 1, 2013 at 5:29
Add a ment  | 

1 Answer 1

Reset to default 3

There are various utility methods available to you that will do this, such as jQuery's extend() function. Or you could write your own function to achieve this as described here:

How can I merge properties of two JavaScript objects dynamically?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745604758a4635608.html

相关推荐

  • Javascript Object - prepend object to existing object - Stack Overflow

    I have this javascript objects.<script language="javascript" type="textjavascript&

    3小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信