ES6中的includes方法

在进行判断时,要包括很多选择,这时可以用到includes

比如,if(type==1||type==2||type==3)

定义一个变量进行接收,const array = [1,2,3]

if(array.includes(type)){

}

posted @ 2022-12-27 11:18  锦呀  阅读(173)  评论(0)    收藏  举报