Valeurs d'extrait JavaScript

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);
Carsten Schlegel