5

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?

coffeemonitor
  • 12,780
  • 34
  • 99
  • 149
  • 1
    Possible duplicate : [How can I merge properties of two JavaScript objects dynamically?](http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically) – Pascalz Oct 01 '13 at 05:01
  • What does "beginning of the variable" mean? JavaScript objects are unordered. There is no beginning. – user2736012 Oct 01 '13 at 05:29

1 Answers1

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?

Community
  • 1
  • 1
ColinE
  • 68,894
  • 15
  • 164
  • 232