javascript中的obj..prop语法是什么? [英] What is the obj?.prop syntax in javascript?

查看:177
本文介绍了javascript中的obj..prop语法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在看一个代码,碰到了这个问题:

I was looking through a code and I came across this:

{{abc?.xvy=== tyu?abc?.xz:abc?.xz}}

我无法理解此表达式的含义。我知道这是Null安全的属性访问,但是我对链接有点困惑。
非常感谢任何帮助

I am unable to understand meaning of this expression. I know that it is Null-safe property access but I am bit confused about the chaining. Any help is much appreciated

推荐答案

其新的ES提案称为可选,用于安全检查对象属性。上面的表达式等于:

Its new ES proposal called "optionals" for safe check reading for object properties. Above expression is equivalent to:

(abc && abc.xvy) === (tyu) ? (abc && abc.xz) : (abc && abc.xz)

您可以在此处找到更多详细信息: https://github.com/davidyaha/ecmascript-optionals-proposal

You can find more details here: https://github.com/davidyaha/ecmascript-optionals-proposal

这篇关于javascript中的obj..prop语法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆