分类 JavaScript 下的文章

ES6 learning(入门)第三记


循环对象可迭代的对象迭代的方法let list = [10, 20, 30]; let str = '你好哦'; let map = new Map(); map.set('JS', 'JavaScript'); map.set('P', 'PHP'); map.set('PY', 'Python'); for(let val of list) { console.log(val); } for(let val of str) { console.log(val); } for(let [key, value] of map) { console.log(key, value); }let item = map.value(); let temp; while(temp = item.next()) { if(temp.d...

ES6 learning(入门)第二记


解构赋值解构赋值的写法数组赋值let [a, b, c] = [10, 20, 30]; console.log(a, b, c);let [x, y, ...other] = [1, 2, 3, 4, 5]; console.log(x, y, other);对象赋值let {name, age} = {name: 'fmujie', age: 18}; console.log(name, age);函数赋值function test() { return [10, 20]; } let [num1, num2] = test(); console.log(num1, num2);函数参数名指定function test({x=3, y=3}) { return x + y; } console.log(test()); console.lo...

ES6 learning(入门)第一记


let命令用let命令限定作用域变量 i 的作用域//ES5 if (true) { var i = 1; } console.log(i);//ES6 if (true) { let i = 1; } console.log(i)重复定义var i = 0; switch (i) { case 0: let value = "hello"; case 1: let value = "world"; }常量定义const关键字const data = 10; console.log(data); //data = 100 //执行错误const list = [10, 20, 30]; console.log(list); list[0] = 100; c...

召唤看板娘