1、数组复制
1 2
| const arr1 = [1, 2, 3]; const arr2 = [...arr1];
|
2、字符串输出
1 2 3
| const name = "apple"; const number = "2"; console.log(`name:${name}, number:${number}`);
|
3、class
1 2 3 4 5 6
| class Human { constructor(name) { this.name = name; }; getName() { console.log(this.name) }; }
|
4、Object解构
1 2 3
| const group = {man:[1,3,5],woman:[2,4,6]}; const {man} = group; console.log(man);
|
5、数组解构
1 2 3
| const arr1 = [1,2,3,4,5]; const [a,b,c,d,e] = arr1; console.log(`${a},${b},${c},${d},${e}`)
|
6、遍历key值
1 2 3 4 5
| const obj = {a:1,b:2,c:3}; for(let item in obj){ console.log(item); console.log(obj[item]); }
|
7、属性的简洁表示法
1 2 3 4 5 6 7 8 9 10
| let listeners = [] function listen() {} let events = { listeners: listeners, listen: listen }
let listeners = [] function listen() {} let events = { listeners, listen }
|
参考 & 引用
https://zhuanlan.zhihu.com/p/35746653
https://segmentfault.com/a/1190000010159725