1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
function foo() { var x = 'Hello, ' + y; console.log(x); var y = 'Bob'; }
const PI = 3.14;
var [x, y, z] = ['hello', 'JavaScript', 'ES6'];
let [x, [y, z]] = ['hello', ['JavaScript', 'ES6']];
let [, , z] = ['hello', 'JavaScript', 'ES6'];
var person = { name: '小明', age: 20, gender: 'male', passport: 'G-12345678', school: 'No.4 middle school' }; var {name, age, passport} = person;
var person = { name: '小明', age: 20, gender: 'male', passport: 'G-12345678', school: 'No.4 middle school' };
let {name, passport:id} = person
var person = { name: '小明', age: 20, gender: 'male', passport: 'G-12345678' };
var {name, single=true} = person; name; single;
var x, y;
{x, y} = { name: '小明', x: 100, y: 200};
({x, y} = { name: '小明', x: 100, y: 200});
var x=1, y=2; [x, y] = [y, x]
function buildDate({year, month, day, hour=0, minute=0, second=0}) { return new Date(year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second); }
buildDate({ year:2017, month:1, day:1 });
|