es6+字符串string的新增方法函数

时间:2019-06-11 10:57:51   收藏:0   阅读:181

String.includes("xxx")   返回true/false     [es5的字符串查找方法:String.indexOf()  ]

String.startsWith("xxx")  判断字符串是否以 "xxx" 开头  返回 true/false

String.endsWith("xxx")  判断字符串是否以 "xxx" 结尾  返回 true/false

String.repeat(x)   重复字符串 x 几次 列如:let str="aabb"; str.repeat(3);==>"aabbaabbaabb" 

String.padStart(整个字符串长度,想填充的东西)  例如:"a".padStart("4","xxx");==>"xxxa"

原文:https://www.cnblogs.com/XCWebLTE/p/11002300.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!