if(true){
let a=1;
}
console.log(a);//undifined
for(let i=0;i<lists.length;i++){
//do somthing with lists[i]
}
console.log(i)l//undifined
const MY_CONSTENT=1; MY_CONSTENT=2;//error const MY_CONSTENT;//error
const MY_OBJECT={some:1};
MY_OBJECT.some='body';
//箭头函数
let books=[{"title":"X","price":20},{"title":"Y","price":40}];
let titles=books.map(item=>item.title);
//ES5函数
var titles=books.map(function(item){
return item.title;
});
//no arguments books.map(()=>1);//[1,1] //Mutiple arguments [1,2].map((n,index)=>n*index);//[0,2]
let result=[1,2,3,4,5].map(n=>{
n=n%3;
retutn n;
})
//ES6
let books={
title'X',
sellers:['A','B'],
printSellers(){
this.sellers.forEach(seller=>console.log(seller+'seller'+this.title))
}
};
//ES5
var books={
title='X',
sellers:['A','B'],
printSellers:function(){
var that=this;
this.sellers.forEach(function(seller){
console.log(seller+'seller'+that.title)
})
}
};
'my string'.startsWith('my');//true
'my string'.endsWith('my');//false
'my string'.includes('str');//true
'my'.repeat(3);//'my my my'
//ES6
let name='json',
apples=5,
pears=7,
bananas=function(){return 3};
console.log('this is${name}');
console.log('he carries ${apples} apples,${pears} pears,and ${bananas()} bananas');
//ES5
console.log('he carries'+ ${apples}+' apples,'+${pears}+' pears,and '+${bananas()}+' bananas');
let x='1... 2... 3 lines long!'; //ES5 var x='1...'+ '2...'+ '3 lines long!'; var x="1...2...3 lines long!';
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有