es6语法中新增哪些操作字符串方法

713 ℃

es6语法中新增哪些操作字符串方法,下面web建站小编给大家详细介绍一下具体实现方法!

codePointAt()

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

normalize()

'\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

padStart(),padEnd()

console.log('输出结果:', 'abcde'.padStart(2, 'ab')) //输出结果: abcde
console.log('输出结果:', 'abcde'.padEnd(2, 'ab')) //输出结果: abcde

filter实现数组过滤,es6语法过滤方法合集

ES6语法中有哪些简单的字符串转数组方法

ES6如何实现模块化编程

ES6语法种有哪些判断方法

Normalize.css文档官网介绍

标签: codePointAt, endsWith, es6字符串方法, es6语法, includes, normalize, padEnd, padStart, startsWith

上面是“es6语法中新增哪些操作字符串方法”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。

当前网址:https://m.ipkd.cn/webs_3877.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

生活小工具

收录了万年历、老黄历、八字智能排盘等100+款小工具!生活小工具
网站被降权的主要原因有哪些(解决办法)
es6之扩展运算符三个点(... )
Nephola
利用js做一个炫酷音乐背景效果
js如何利用reduce获取数组中最大值和最小值