
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 04:06 AM
I have lists of objects in my code they represent weeks form the time_card table, i have 2 combineddata from 2 different weeks(time sheet) in order to send them in to our company's time registration application.
My example code ;
var obja ={};
var objb ={};
obja[1]={}
obja[1].a = 1
obja[1].b = 2
obja[2]={}
obja[2].a = 11
obja[2].b = 22
objb[3]={}
objb[3].a = 1
objb[3].b = 2
objb[4]={}
objb[4].a = 11
objb[4].b = 22
I want to combind the 2 objects obja and objb in to objc containing 1 - 4
In Java Script I found the method Object.assign()
But I cant get it to work it looks like the method doesn't work.
Am I missing some thing or is there an other method.
I can combined them by looping them through and adding the data in to the target object but now I'm just looking for a nicer solution.
Mostly for readability
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 12:11 PM
Solved this but a bit ugly
var obj = {};
obj = populate_obj(seed,ojb)
function populate_obj(seed, imp_obj){
//do magic stuff and add stuff to my object
return imp_obj;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 12:11 PM
Solved this but a bit ugly
var obj = {};
obj = populate_obj(seed,ojb)
function populate_obj(seed, imp_obj){
//do magic stuff and add stuff to my object
return imp_obj;
}