购物车
登陆 / 注册
微信扫码登陆

推荐手册

ES 6 String includes()

ES 6 String includes()
includes()方法确定字符串是否是给定字符串的子字符串。
灭绝小师太 灭绝小师太 更新时间:2019-06-19 11:56:52

ES 6 String includes()

includes()方法确定字符串是否是给定字符串的子字符串。

语法:

str.includes(searchString[, position])

参数:

● searchString - 要搜索的子字符串。

● Position - 此字符串中开始搜索searchString的位置; 默认为0。

返回值:

如果字符串包含子字符串,则为true ; 否则,错误。

例:

var str = 'Hello World';  
console.log(str.includes('hell'))     
console.log(str.includes('Hell'));  
console.log(str.includes('or'));   
console.log(str.includes('or',1))

输出:

false 
true 
true 
true
网站导航
标签地图
学习路径
视频教程
开发软件
旗下子站
php中文网
phpstudy
技术文章
文档工具
关于我们
企业合作
人才招聘
联系我们
讲师招募
QQ交流群
QQ官方交流群
微信公众号
微信公众号