前端小技巧

1. 在进行字符串中是否含有某个指定字符或值判断时候,除了可以通过indexOf和正则匹配,还可以通过最新的includes进行判断。如下:

const a = 'pc/h5/test'
const b = a.includes('/h5/')
console.log(b) // true

 

posted @ 2020-06-13 17:24  爱上大树的小猪  阅读(124)  评论(0编辑  收藏  举报