Suppose I have an array of objects like this:
var nodes = [{"size":8,"name":"myName"},{"size":10,"name":"otherName"},{"size":11,"name":"userName"}];
How do I create an array arr that contains objects mapped from nodes but that the attributes have different names. Say I want that arr.r be mapped to each size attribute, so:
thisSize = arr[0].r
should assing 8 to thisSize.
Hope I explained my question clearly.
You can use properties or
mapif you’re not worried about supporting Internet Explorer 8 and earlier, but I’ll assume you are. Just iterate and construct a new array with new objects:Map your properties in the object
pushed as necessary.