标签:efi const on() var function 箭头 func ber window
var foo = function(){return 1;};
//等价于
let foo = () => 1;
箭头函数中的 this 指的不是window,是对象本身。
function aa(){
this.bb = 1;
setTimeout(() => {
this.bb++; //this指向aa
console.log(this.bb);
},500);
}
aa(); //2
我们都知道for in
循环用于遍历数组,类数组或对象,ES6中新引入的for of
循环功能相似,不同的是每次循环它提供的不是序号而是值
var someArray = [ "a", "b", "c" ];
for (v of someArray) {
console.log(v);//输出 a,b,c
}
解构赋值是ES6中推出的一种高效、简洁的赋值方法
//通常情况下
var first = someArray[0];
var second = someArray[1];
var third = someArray[2];
//解构赋值
let [first, second, third] = someArray; //比上面简洁多了吧
//还有下面例子
let [,,third] = [1,2,3];
console.log(third); //3
let [first,...last] = [1,2,3];
console.log(last); //[2,3]
//对象解构
let {name,age} = {name: "lisi", age: "20"};
console.log(name); //lisi
console.log(age); //20
let {ept} = {};
console.log(ept); //undefined
标签:efi const on() var function 箭头 func ber window
原文地址:https://www.cnblogs.com/IT123/p/10899367.html