const arr = [1, 2, 3, 4]
let [num1, num2, num3, num4] = arr
console.log(num1, num2, num3, num4) // 1 2 3 4
const obj = {
name: '名字',
age: '18',
eat: function (food) {
console.log('吃' + food)
}
}
let { name, age, eat } = obj
console.log(name, age, eat)
/*
* 名字 18 ƒ (food) {
* console.log('吃' + food)
* }
*/
eat('水果') // 吃水果