var arr =['a','b','c'];
console.log("===============");
console.log("for in:");//遍历:数组,对象; 推荐遍历对象,因为它的下标是字符串for(var index in arr){
console.log("键", index,"值", arr[index])}
4.for of:
console.log("===============");
console.log("for of:");//遍历:数组,字符串,映射,集合等数据结构 只取出值,varset=newSet([1,2,3,4]);//for of获取值for(var val ofset){
console.log("值", val);}var a =['g','d','j'];//for of获取数组索引 //keys():从数组中创建迭代对象,该对象包含了数组的键;返回的是一个迭代对象for(var index of arr.keys()){
console.log(index);}
二、函数扩展:
1.ES6以后函数的参数可以写默认值
functionf(name ="jhh", age =20){
console.log("name", name,"age", age);}f();