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

ES2020 #6

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

ES2020 #6

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

?.可选链操作符

tc39/proposal-optional-chaining

obj?.prop       // optional static property access
obj?.[expr]     // optional dynamic property access
func?.(...args) // optional function or method call

等价关系

a?.b   // undefined if `a` is null/undefined, `a.b` otherwise.
a == null ? undefined : a.b

注意falseBoolean对象的实例,因此false.b值为undefined,不会报错。
同理a=0时,a.b值为undefined也不会报错,只是在语法上0.b直接这么写会报错

??空值合并操作符

tc39/proposal-nullish-coalescing
行为类似||,但假值只有nullundefined,有效值0false''

export {v} from 'mod'

tc39/proposal-export-ns-from

globalThis

tc39/proposal-global
统一获取浏览器、Web Worker、Node.js环境的顶层对象,可替代windowselfglobal

str.matchAll()

tc39/proposal-string-matchall
str.match(regex)对于regex是否存在修饰符g表现不同,使用matchAll可以实现类似match多次匹配的效果

Promise.allSettled()

tc39/proposal-promise-allSettled

BigInt

tc39/proposal-bigint
这是 ECMAScript 的第八种数据类型。
BigInt 只用来表示整数,没有位数的限制,任何位数的整数都可以精确表示。

import() 动态导入

tc39/proposal-dynamic-import

import.meta

tc39/proposal-import-meta
规范中说meta是一个可读写的属性,并例举了meta的2种属性urlscriptElement用法,但没有对所有属性进行规范。
根据MDN文档,只能确定import.meta.url存在

规范for-in循环枚举字段的顺序

tc39/proposal-for-in-order
由于涉及浏览器引擎实现,不能或者不值得polyfill,因此该项改进可以忽略。

参考资料

@luoway luoway added the deploy deploy to gh-page label Jun 25, 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