Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES2019 #5

Open
luoway opened this issue Jun 24, 2023 · 0 comments
Open

ES2019 #5

luoway opened this issue Jun 24, 2023 · 0 comments
Labels
deploy deploy to gh-page

Comments

@luoway
Copy link
Owner

luoway commented Jun 24, 2023

String.prototype

  • trimStart
    • 别名trimLeft
  • trimEnd
    • 别名trimRight

Array.prototype

  • flat
    [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]
  • flatMap
    // 相当于 [[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

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()方法返回函数代码本身,以前会省略注释和空格,修改后,明确要求返回一模一样的原始代码。

参考资料

@luoway luoway added the deploy deploy to gh-page label Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy deploy to gh-page
Projects
None yet
Development

No branches or pull requests

1 participant