Saturday, 3 July 2021

filter only values from object list

 

// ES5
var arrayObjects = [
{
name: "A",
surname: "1"
},
{
name: "B",
surname: "2"
},
{
name: "C",
surname: "3"
}
];
Array.prototype.map.call(arrayObjects, function(item) { return item.name; }).join(","); // "A,B,C"
// ES6 / TypeScript
const arrayObjects = [
{
name: "A",
surname: "1"
},
{
name: "B",
surname: "2"
},
{
name: "C",
surname: "3"
}
];
Array.prototype.map.call(arrayObjects, s => s.name).toString(); // "A,B,C" refer this site

No comments:

Post a Comment

Meet BootUI | Scan AI-Generated Code & Find What AI Missed !

 very usefull link to verify ai content https://www.youtube.com/watch?v=pULGt0Rme58 Click