This question already has answers here:
From an array of objects, extract value of a property as array
(24 answers)
Closed 3 years ago.
Here is my code. (sorry about ugly json data)
var data = [{"ImageSets":[{"ImageSet":[{"$":{"Category":"variant"},"SwatchImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL30_.jpg"],"Height":[{"_":"30","$":{"Units":"pixels"}}],"Width":[{"_":"30","$":{"Units":"pixels"}}]}],"SmallImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"ThumbnailImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"TinyImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL110_.jpg"],"Height":[{"_":"110","$":{"Units":"pixels"}}],"Width":[{"_":"110","$":{"Units":"pixels"}}]}],"MediumImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL160_.jpg"],"Height":[{"_":"160","$":{"Units":"pixels"}}],"Width":[{"_":"160","$":{"Units":"pixels"}}]}],"LargeImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL.jpg"],"Height":[{"_":"500","$":{"Units":"pixels"}}],"Width":[{"_":"500","$":{"Units":"pixels"}}]}],"HiResImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/81OWhCeCRtL.jpg"],"Height":[{"_":"2560","$":{"Units":"pixels"}}],"Width":[{"_":"2560","$":{"Units":"pixels"}}]}]},{"$":{"Category":"variant"},"SwatchImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL30_.jpg"],"Height":[{"_":"30","$":{"Units":"pixels"}}],"Width":[{"_":"30","$":{"Units":"pixels"}}]}],"SmallImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"ThumbnailImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"TinyImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL110_.jpg"],"Height":[{"_":"110","$":{"Units":"pixels"}}],"Width":[{"_":"110","$":{"Units":"pixels"}}]}],"MediumImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL160_.jpg"],"Height":[{"_":"160","$":{"Units":"pixels"}}],"Width":[{"_":"160","$":{"Units":"pixels"}}]}],"LargeImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL.jpg"],"Height":[{"_":"500","$":{"Units":"pixels"}}],"Width":[{"_":"500","$":{"Units":"pixels"}}]}],"HiResImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/71e4eChoGzL.jpg"],"Height":[{"_":"2560","$":{"Units":"pixels"}}],"Width":[{"_":"2560","$":{"Units":"pixels"}}]}]},{"$":{"Category":"variant"},"SwatchImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL30_.jpg"],"Height":[{"_":"30","$":{"Units":"pixels"}}],"Width":[{"_":"30","$":{"Units":"pixels"}}]}],"SmallImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"ThumbnailImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"TinyImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL110_.jpg"],"Height":[{"_":"110","$":{"Units":"pixels"}}],"Width":[{"_":"110","$":{"Units":"pixels"}}]}],"MediumImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL160_.jpg"],"Height":[{"_":"160","$":{"Units":"pixels"}}],"Width":[{"_":"160","$":{"Units":"pixels"}}]}],"LargeImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL.jpg"],"Height":[{"_":"500","$":{"Units":"pixels"}}],"Width":[{"_":"500","$":{"Units":"pixels"}}]}],"HiResImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/71qsXsLLRWL.jpg"],"Height":[{"_":"2560","$":{"Units":"pixels"}}],"Width":[{"_":"2560","$":{"Units":"pixels"}}]}]},{"$":{"Category":"variant"},"SwatchImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL30_.jpg"],"Height":[{"_":"30","$":{"Units":"pixels"}}],"Width":[{"_":"30","$":{"Units":"pixels"}}]}],"SmallImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"ThumbnailImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"TinyImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL110_.jpg"],"Height":[{"_":"110","$":{"Units":"pixels"}}],"Width":[{"_":"110","$":{"Units":"pixels"}}]}],"MediumImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL160_.jpg"],"Height":[{"_":"160","$":{"Units":"pixels"}}],"Width":[{"_":"160","$":{"Units":"pixels"}}]}],"LargeImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL.jpg"],"Height":[{"_":"500","$":{"Units":"pixels"}}],"Width":[{"_":"500","$":{"Units":"pixels"}}]}],"HiResImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/91hyvNK4stL.jpg"],"Height":[{"_":"2560","$":{"Units":"pixels"}}],"Width":[{"_":"2560","$":{"Units":"pixels"}}]}]},{"$":{"Category":"variant"},"SwatchImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL30_.jpg"],"Height":[{"_":"30","$":{"Units":"pixels"}}],"Width":[{"_":"30","$":{"Units":"pixels"}}]}],"SmallImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"ThumbnailImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"TinyImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL110_.jpg"],"Height":[{"_":"110","$":{"Units":"pixels"}}],"Width":[{"_":"110","$":{"Units":"pixels"}}]}],"MediumImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL160_.jpg"],"Height":[{"_":"160","$":{"Units":"pixels"}}],"Width":[{"_":"160","$":{"Units":"pixels"}}]}],"LargeImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL.jpg"],"Height":[{"_":"500","$":{"Units":"pixels"}}],"Width":[{"_":"500","$":{"Units":"pixels"}}]}],"HiResImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/816DOkjvgKL.jpg"],"Height":[{"_":"2560","$":{"Units":"pixels"}}],"Width":[{"_":"2560","$":{"Units":"pixels"}}]}]},{"$":{"Category":"variant"},"SwatchImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL30_.jpg"],"Height":[{"_":"30","$":{"Units":"pixels"}}],"Width":[{"_":"30","$":{"Units":"pixels"}}]}],"SmallImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"ThumbnailImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"TinyImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL110_.jpg"],"Height":[{"_":"110","$":{"Units":"pixels"}}],"Width":[{"_":"110","$":{"Units":"pixels"}}]}],"MediumImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL160_.jpg"],"Height":[{"_":"160","$":{"Units":"pixels"}}],"Width":[{"_":"160","$":{"Units":"pixels"}}]}],"LargeImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL.jpg"],"Height":[{"_":"500","$":{"Units":"pixels"}}],"Width":[{"_":"500","$":{"Units":"pixels"}}]}],"HiResImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/819xXjN-ghL.jpg"],"Height":[{"_":"2560","$":{"Units":"pixels"}}],"Width":[{"_":"2560","$":{"Units":"pixels"}}]}]},{"$":{"Category":"primary"},"SwatchImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL30_.jpg"],"Height":[{"_":"30","$":{"Units":"pixels"}}],"Width":[{"_":"30","$":{"Units":"pixels"}}]}],"SmallImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"ThumbnailImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL75_.jpg"],"Height":[{"_":"75","$":{"Units":"pixels"}}],"Width":[{"_":"75","$":{"Units":"pixels"}}]}],"TinyImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL110_.jpg"],"Height":[{"_":"110","$":{"Units":"pixels"}}],"Width":[{"_":"110","$":{"Units":"pixels"}}]}],"MediumImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL160_.jpg"],"Height":[{"_":"160","$":{"Units":"pixels"}}],"Width":[{"_":"160","$":{"Units":"pixels"}}]}],"LargeImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL.jpg"],"Height":[{"_":"500","$":{"Units":"pixels"}}],"Width":[{"_":"500","$":{"Units":"pixels"}}]}],"HiResImage":[{"URL":["https://images-na.ssl-images-amazon.com/images/I/71-w1EWOaWL.jpg"],"Height":[{"_":"2560","$":{"Units":"pixels"}}],"Width":[{"_":"2560","$":{"Units":"pixels"}}]}]}]}]}]
data[0].ImageSets[0].ImageSet.forEach((image) => {
var images = image.LargeImage[0].URL[0]
console.log(images)
})
I'm getting all URL's in console log.
I tried to merge them with split() but it's not working. Each string is getting its own array. Similarly if i use var images = image.LargeImage[0].URL. Each string return it's own array.
What i want is a single array with all URL's like this.
["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL.jpg", "https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL.jpg", "https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL.jpg", "https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL.jpg", "https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL.jpg", "https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL.jpg","https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL.jpg"]
Thanks.
It makes more sense here to just use .map(), as it will create a new Array with the return value of each iteration
var data=[{ImageSets:[{ImageSet:[{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/81OWhCeCRtL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/71e4eChoGzL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/71qsXsLLRWL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/91hyvNK4stL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/816DOkjvgKL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/819xXjN-ghL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"primary"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/71-w1EWOaWL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]}]}]}];
let urlsArray = data[0].ImageSets[0].ImageSet.map((image) => {
return image.LargeImage[0].URL[0];
});
console.log(urlsArray);
This is how you would do it with .forEach(), additionally
var data=[{ImageSets:[{ImageSet:[{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41NeQS3RMzL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/81OWhCeCRtL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/316W1tHrMuL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/71e4eChoGzL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/31TgrPVXYjL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/71qsXsLLRWL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/51qcfjgaAZL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/91hyvNK4stL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41numbb3sgL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/816DOkjvgKL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"variant"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41PLx0E2sqL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/819xXjN-ghL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]},{$:{Category:"primary"},SwatchImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL30_.jpg"],Height:[{_:"30",$:{Units:"pixels"}}],Width:[{_:"30",$:{Units:"pixels"}}]}],SmallImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],ThumbnailImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL75_.jpg"],Height:[{_:"75",$:{Units:"pixels"}}],Width:[{_:"75",$:{Units:"pixels"}}]}],TinyImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL110_.jpg"],Height:[{_:"110",$:{Units:"pixels"}}],Width:[{_:"110",$:{Units:"pixels"}}]}],MediumImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL._SL160_.jpg"],Height:[{_:"160",$:{Units:"pixels"}}],Width:[{_:"160",$:{Units:"pixels"}}]}],LargeImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/41bz4b5IbLL.jpg"],Height:[{_:"500",$:{Units:"pixels"}}],Width:[{_:"500",$:{Units:"pixels"}}]}],HiResImage:[{URL:["https://images-na.ssl-images-amazon.com/images/I/71-w1EWOaWL.jpg"],Height:[{_:"2560",$:{Units:"pixels"}}],Width:[{_:"2560",$:{Units:"pixels"}}]}]}]}]}];
let urlsArray = [];
data[0].ImageSets[0].ImageSet.map((image) => {
urlsArray.push(image.LargeImage[0].URL[0]);
});
console.log(urlsArray);