[关闭]
@windchimes 2019-06-25T09:07:08.000000Z 字数 417 阅读 276

es7 and es8

js


es7新增加了两个新属性:
1)Array.prototype.includes

  1. let arr = [1,2,3,4];
  2. arr.includes(2) //true

2)幂运算 **

  1. let a = 2;
  2. console.log(a**3) //8

es8新增的属性有:
1)允许结尾逗号

  1. let obj = {
  2. a,
  3. b,
  4. c,
  5. }

2)Object.entries Object.values

  1. Object.entries({foo:1,bar:2}) // [['foo':1],['bar':2]]
  2. Object.values({foo:1,bar:2}) // [1,2]

3)字符串填充 padStart padEnd trimStart trimEend

  1. console.log('testing'.padStart(12).length) //' testing'
  2. console.log('testing).padStart(12, '_') //'______testing'
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注