1、查询是否包含赢一个字符串
'xxxx'.includes(x,i);//x子字符串,i起始位置
2、forEach(数组的循环不能中断)
array.forEach(function(currentValue,index,array){})
//必须 currentValue: 当前的元素
//可选 index:当前元素的索引值
//可选 array: 当前元素所属的数组对象
3、创建类
class Human {
constructor(name) {
this.name = name;
}
breathe() {
console.log(this.name + " is breathing");
}
}
var human = new Human("yancy");
human.breathe();//yancy is breathing
//继承
class Man extends Human {
constructor(name,sex){
super(name);//es6语法 访问父级对象上的构造函数
this.sex = sex;
}
info(){
console.log(`${this.name} is ${this.sex}`);
}
}
var man = new Man('henry','boy');
man.breathe();//henry is breathing
man.info();//henry is boy
4、箭头函数
var arr = ['A', '', 'B', null, undefined, 'C', ' '];//删掉空字符串
var newArr = arr.filter( val => (val && val.trim()));//newArr = ['A','B','C']