代码中使用let代替var
var ===>>> let
常量的定义方式
const a = 1
const b = 2 ===>>> const [a, b, c] = [1, 2, 3]
const c = 3
静态字符串一律使用单引号或反引号,不使用双引号。动态字符串使用反引号
const a = "hello" const a = "hello"
==>>>>
const b = a + "world" const b = `${a}world`
数组copy
const len = items.length;
const itemsCopy = [];
let i;
for (i = 0; i < len; i++) {
itemsCopy[i] = items[i];
}
===>>>
const itemsCopy = [...items];
函数书写
(function() {})() ==>>> ()=>{}
const acceptMethod = method.bind(this); ===>>> const goodMethod = (…params) => method.apply(this, params)