
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,我们会在看到邮件的第一时间内为您处理!

jquery哪些版本可以兼容IE8
新站备案与不备案对百度收录影响到底有多大
智谱AI大模型开放平台:一个基于“模型即服务”(MaaS)理念的先进人工智能平台