var regularPerson = { firstName: "Bill", lastnNme: "Wilson" } var lordify = ({firstName}) => { console.log(`${firstName} of Canterbury`; } lordify(regularPerson); // Bill of Canterbury
数组解构赋值
1 2 3 4
var [firstResort] = ["Kirkwood", "Squaw", "Alpine"]; console.log(firstResort); // kirkwood var [,,thirdResort] = ["Kirkwood", "Squaw", "Alpine"]; console.log(thirdResort]; // Alpine
字符串解构赋值
1 2 3 4 5 6
var [a, b, c, d, e = "hello"; a // "h" b // "e" c // "l" d // "l" e // "o"