Message from JavaScript discussions

July 2017

— Ah isee, btw can you help me and tell how to combine all of the objects and render it as a table?


You can make a new object and assign the same properties (they will not be copied, just referenced) using Object.assign()

— All args in that read from right to left, the rightmost overriding the left

— var combined = Object.assign({}, obj1, obj2);

— If obj1 has a prop like hello, and obj2 does too, then the prop in obj2 will override (not overwrite, obj1 will remain the same) that prop in the new object

Message permanent page

— Basically arg 1 is a target object, which is what will be mutated directly

— Can you order it for me please

— Erm, well a JSON array is naturally ordered

— You can maybe order it in a way of your choosing by using Object.entries(obj)

— So something like
var myArray = Object.entries(obj).sort(compareFunction);

— What kind of order do you want, alphabetical?

— I want the created date to come out I descending order