Wert aus dem Array von Objekten JavaScript extrahieren
let result = objArray.map(a => a.foo);
Index out of bounds
let result = objArray.map(a => a.foo);
const data = {
"Name": "John Doe",
"Age": 99,
"Gender": "m",
"Childs": ["Max", "Anna", "Phil"]
}
// Properties with Variablename = Propertyname
var { Name, Age, Gender } = data;
console.log(Name + " is " + Age + "Year old.");
// Properties with custom Variablename
var { Name: n } = data;
console.log(n);
// Extract Array
var { Childs } = data;
console.log(Childs);
// Extract from Array
var [child1, child2, child3] = Childs;
console.log("First: " + child1 + ", Second: " + child2, ", Third: " + child3);
var obj = {v1: 'v1', v2: 'v2'};
// extract object's values as array
var valuesArray = Object.values(obj); // ['v1','v2']