<p>includes():返回布尔值,表示是否找到了参数字符串</p>
<p>startsWith():返回布尔值,表示参数字符串是否在源字符串的开头</p>
<p>endsWith():返回布尔值,表示参数字符串是否在源字符串的结尾</p>
<b>注:都支持第二个参数,表示搜索的位置</b>
<p>repeat():表示重复n次 返回新的字符串</p>
<p></p>
<p></p>
<p></p>
<script src="demo.js"></script>
<script>
var s='hello world! 刘伟光';
console.log(s.includes('刘'),"includes") //true
console.log(s.startsWith('llo'),"startsWith") //false
console.log(s.endsWith('光'),"includes") //true
console.log('lo'.repeat(3),'repeat')
</script>
es6 字符串包含
最新推荐文章于 2024-04-25 11:14:20 发布