ES2019
String.prototype
trimStart- 别名
trimLeft
- 别名
trimEnd- 别名
trimRight
- 别名
Array.prototype
- flatjs
[1, 2, , [4, 5]].flat() // [1, 2, 4, 5] [1, 2, [3, [4, 5]]].flat(2) // [1, 2, 3, 4, 5] [1, [2, [3]]].flat(Infinity) // [1, 2, 3] - flatMapjs
// 相当于 [[2, 4], [3, 6], [4, 8]].flat() [2, 3, 4].flatMap((x) => [x, x * 2]) // [2, 4, 3, 6, 4, 8] - sort
数组的排序稳定性
Object.fromEntries()
Object.fromEntries()方法是Object.entries()的逆操作,用于将一个键值对数组转为对象。
Symbol.prototype.description
js
const sym = Symbol('foo')
String(sym) // "Symbol(foo)"
sym.toString() // "Symbol(foo)"
sym.description // "foo"try { } catch { }
直接输入 U+2028 和 U+2029
JSON.stringify() 的改进
fn.toString()的改进
Function.prototype.toString()方法返回函数代码本身,以前会省略注释和空格,修改后,明确要求返回一模一样的原始代码。