ES6基础知识(字符串新方法)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>字符串新方法</title> </head> <body> <script> let str = '字符串新方法'; console.log(str.includes('方'));//查询指定字符是否在目标字符串中,返回布尔值 true console.log(str.includes('方',5));//第二个参数是指定开始查找位置 false console.log(str.startsWith('字'));//查询指定字符串是否在目标字符串起始位置,第二个参数用法同上 true console.log(str.endsWith('法'));//查询指定字符串是否在目标字符串结束位置,第二个参数用法同上 false console.log(str.repeat(2));//重复字符串 字符串新方法字符串新方法 </script> </body> </html>
备注:文中多数内容摘自阮一峰老师文章,仅供自我学习查阅。
https://edu.51cto.com/lecturer/11857712.html 星星课堂web前端系列课程
https://edu.51cto.com/course/25959.html js设计模式课程
https://edu.51cto.com/course/23133.html js进阶与组件化实战课程
https://edu.51cto.com/course/24757.html jquery课程
https://edu.51cto.com/course/22392.html js基础与入门课程
https://edu.51cto.com/course/26063.html vue零基础入门课程
https://edu.51cto.com/course/22393.html xhtml与css基础入门课程