-
数组解构赋值在企业开发中的应用场景
-
数组解构赋值前
let arr = [1, 3]; function sum(a, b) { return a + b; } let res = sum(arr[0], arr[1]); console.log(res);
-
数组解构赋值后
let arr = [1, 3]; function sum([a, b]) { return a + b; } let res = sum(arr); console.log(res);
-
-
对象解构赋值在企业开发中的应用场景
-
对象解构赋值前
let obj = { name: "lnj", age: 34 } function say(name, age) { console.log(name, age); } say(obj.name, obj.age);
-
对象解构赋值后
let obj = { name: "lnj", age: 34 } function say({name, age}) { console.log(name, age); } say(obj);
-
网友评论