//http://www.jianshu.com/p/ebfeb687eb70
//循环数组
var arr=[1,2,3];
arr.forEach(function(v,i,a){
console.log(v+" "+i+" "+a);
});
//类
class Animal {
constructor(name){
this.name=name;
}
myName(){
setTimeout(()=>{
console.log("当前名字:"+this.name);
},1000);
console.log('name:'+this.name);
}
}
new Animal('dog').myName();
//let 作用域内
let ceo='YU';
console.log(ceo);
if(1==1){
let ceo='WANG';
console.log(ceo);
}
console.log(ceo);
//destructuring
let dog='xiaobai';
let cat='laibao';
let animals={dog,cat};
console.log(animals);
//let dog = {type: 'animal', many:2};
//let { type, many} = dog;
//console.log(type, many) ; //animal 2
//default
function say(msg='非常好'){
console.log(msg);
}
say();
say('very good');
JavaScript ES6/ES2015核心
最新推荐文章于 2024-11-03 22:08:01 发布