We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
只选取了部分进行翻译
typeof
prototype
function test(name){ this.name = name } new test('a') // {name: 'a'}
Function
Date
new
New表达式:new NewExpression
MemberExpression:new MemberExpression Arguments
MDN
SuperProperty:super [ Expression ]
对应 super[expr] 这种调用
SuperProperty:super . IdentifierName
对应 super.IdentifierName 这种调用
SuperCall:super Arguments
MDN @babel/plugin-proposal-optional-chaining (babel支持)
Chrome v79 版本支持可选链,但是需要手动设置,浏览器url地址栏输入chrome://flags打开,搜索 Experimental JavaScript,选择启用。
const adventurer = { name: 'Alice', cat: { name: 'Dinah' } }; const dogName = adventurer.dog?.name; console.log(dogName); // undefined console.log(adventurer.someNonExistentMethod?.()) // undefined // 使用 nullish 合并运算符设置一个默认值 let customer = { name: "Carl", details: { age: 82 } }; let customerCity = customer?.city ?? "Unknown city"; console.log(customerCity); // Unknown city
OptionalExpression :
MemberExpression OptionalChain
CallExpression OptionalChain
OptionalExpression OptionalChain
参数 baseValue 和 baseReference
OptionalChain : ?. Arguments
OptionalChain : ?. [ Expression ]
OptionalChain : ?. IdentifierName
OptionalChain : OptionalChain Arguments
OptionalChain : OptionalChain [ Expression ]
OptionalChain : OptionalChain . IdentifierName
ImportCall : import ( AssignmentExpression )
The text was updated successfully, but these errors were encountered:
No branches or pull requests
左侧表达式
new 操作符
typeof
结果为 'function'。注意:箭头函数不能做构造器,需排除!prototype
Function
,Date
等调用new
,有点特殊,我代码里没有考虑运行时语义:Evaluation
New表达式:new NewExpression
MemberExpression:new MemberExpression Arguments
EvaluateNew
super 关键字
运行时语义:Evaluation
SuperProperty:super [ Expression ]
SuperProperty:super . IdentifierName
SuperCall:super Arguments
GetSuperConstructor
MakeSuperPropertyReference
可选链
Evaluation
OptionalExpression :
MemberExpression OptionalChain
OptionalExpression :
CallExpression OptionalChain
OptionalExpression :
OptionalExpression OptionalChain
ChainEvaluation 链运算
OptionalChain : ?. Arguments
OptionalChain : ?. [ Expression ]
OptionalChain : ?. IdentifierName
OptionalChain : OptionalChain Arguments
OptionalChain : OptionalChain [ Expression ]
OptionalChain : OptionalChain . IdentifierName
Import 调用
Evaluation
ImportCall : import ( AssignmentExpression )
The text was updated successfully, but these errors were encountered: