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
1 Answer
Reset to default 3There 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
评论列表(0条)