The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.
// 简洁对象定义 let a = 'foo', b = 42, c = {}; let o = {a, b, c}; console.log(o); // { a: 'foo', b: 42, c: {} }
// 简洁函数定义 let f = { fun1() { } }; console.log(f); // { fun1: [Function: fun1] }
对象属性动态定义
1 2 3 4 5
let label = 'label1'; let od = { [label]: 6378 }; console.log(od); // { label1: 6378 }
扩展运算符
Spread syntax allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected. rest 参数的逆运算。
1 2 3 4
let to = {'a': 'av', 'b': 'bv'}; let ta = ['1', '2', '3']; console.log([...ta, '4']); // [ '1', '2', '3', '4' ] console.log({...to, 'c': 'cv'}); // es2018 下{'a':'av','b':'bv','c':'cv'}
CREATE TABLE Customer ( CustNo NUMBER NOT NULL, CustName VARCHAR2(200) NOT NULL, Street VARCHAR2(200) NOT NULL, City VARCHAR2(200) NOT NULL, State CHAR(2) NOT NULL, Zip VARCHAR2(20) NOT NULL, PRIMARY KEY (CustNo) ) ;