We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
let a = [1,2,3]; let b = [0, ...a, 4]; // [0,1,2,3,4] let obj = { a: 1, b: 2 }; let obj2 = { ...obj, c: 3 }; // { a:1, b:2, c:3 } let obj3 = { ...obj, a: 3 }; // { a:3, b:2 }
let a = [1,2,3]; let [b, ...c] = a; b; // 1 c; // [2,3] // 也可以 let a = [1,2,3]; let [b, ...[c,d,e]] = a; b; // 1 c; // 2 d; // 3 e; // undefined // 也可以 function test(a, ...rest){ console.log(a); // 1 console.log(rest); // [2,3] } test(1,2,3)
还有类似的
let array = [1, 2, 3, 4, 5]; const { x, y, ...z } = array; // 其中z=[3, 4, 5],注意如果由于array的length不足以完成析构,则会导致z为[] 对象: let obj = { name: 'zhangsan', age: 30, city: 'shenzhen' }; const {name, ...others} = obj; console.log(name); // 'zhangsan' console.log(others); // {age: 30, city: 'shenzhen'}
转至 ChauncyWuBlog
The text was updated successfully, but these errors were encountered:
No branches or pull requests
比如:
比如:
还有类似的
转至 ChauncyWuBlog
The text was updated successfully, but these errors were encountered: