
es6语法中新增哪些操作字符串方法,下面web建站小编给大家详细介绍一下具体实现方法!
let str = 'A';
console.log('输出结果:', str.codePointAt(0)) // 输出结果:65
String.fromCodePoint()
let str = String.fromCharCode(0x20BB7);
console.log('输出结果:', str) // 输出结果:ஷ
字符串的遍历器接口 for of
for (let str of '12345678') {
console.log('输出结果:', str)
}
//输出结果: 1
//输出结果: 2
//输出结果: 3
//输出结果: 4
//输出结果: 5
//输出结果: 6
//输出结果: 7
//输出结果: 8
at()
console.log('输出结果:', 'abcd'.at(2))
//输出结果: c
'\u01D1'==='\u004F\u030C' //false '\u01D1'.length // 1 '\u004F\u030C'.length // 2
includes()
let str = 'Hello world!'; str.startsWith('Hello') // true
startsWith()
let str = 'Hello world!'; str.endsWith('Hello') // true
endsWith()
let str = 'Hello world!';
str.includes('Hello') // true
console.log('输出结果:', 'abcde'.padStart(2, 'ab')) //输出结果: abcde
console.log('输出结果:', 'abcde'.padEnd(2, 'ab')) //输出结果: abcde
标签: codePointAt, endsWith, es6字符串方法, es6语法, includes, normalize, padEnd, padStart, startsWith
上面是“es6语法中新增哪些操作字符串方法”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_3877.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

如何利用bootstrap做一个动态进度条
一个支持130多个平台视频和图片无水印下载工具——KuKuTool
一个无需用户在本地设置环境即可进行编码、原型设计、模型训练和部署的AI应用——Lightning AI
1AI
乐学多思资料库:一个提供了大量的免费文档下载服务