加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

es6学习笔记2-—symbol、变量与作用域

发布时间:2020-12-16 04:20:52 所属栏目:百科 来源:网络整理
导读:1、新的字符串特性 标签模板: String.raw(callSite,...substitutions) : string 用于获

1、新的字符串特性

标签模板:

  • String.raw(callSite,...substitutions) : string

    用于获取“原始”字符串内容的模板标签(反斜杠不再是转义字符):

      > String.raw`` === ''
      true

Unicode 和码点:

  • String.fromCodePoint(...codePoints : number[]) : string

    将数字值转换成 Unicode 码点字,然后返回由码点构成的字符串。

  • String.prototype.codePointAt(pos) : number

    返回在从位置?pos?处开始的码点的数字值(由一个或者两个 JavaScript 字符组成)。

  • String.prototype.normalize(form? : string) : string

    不同的码点组合可能看起来是一样的。?Unicode 标准化?将它们修正为相同的标准值。这对相等比较和字符串搜索很有帮助。对于一般的文本,建议使用?NFC形式。

查找字符串:

  • String.prototype.startsWith(searchString,position=0) : boolean

    position?参数指定了字符串的开始搜索位置。

  • String.prototype.endsWith(searchString,endPosition=searchString.length) : boolean

    endPosition?指定了字符串的结束搜索位置。

  • String.prototype.includes(searchString,position=0) : boolean

    从字符串?position?位置开始搜索,是否包含?searchString?子串。

重复字符串:

  • String.prototype.repeat(count) : string

    返回重复指定次数的字符串。

  • padStart用于头部补全,padEnd用于尾部补全。
'x'.padStart(5,ab') // 'ababx'
4,1)"> 'abax'
'.padEnd( 'xabab'
 'xaba'
**********************
hello'.repeat(2)  "hellohello"
na0)  ""
**********************
var s = Hello world!';

s.startsWith(Hello true
s.endsWith(! true
s.includes(o true
**********************
String.fromCodePoint(0x78,1)">0x1f680,1)">0x79) === xuD83DuDE80y'
 true

"                        

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读