V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
stx0821
V2EX  ›  问与答

ES2020 引入的“链判断运算符”?. 是借鉴 Angular 的安全导航运算符 吗

  •  
  •   stx0821 · 2020-09-23 23:09:49 +08:00 · 861 次点击
    这是一个创建于 1303 天前的主题,其中的信息可能已经有所发展或是发生改变。
    des
        1
    des  
       2020-09-23 23:21:05 +08:00
    我记得有好几个语言支持这种操作,比如 ruby:account&.owner&.address
    swifter 也是用"?"的,借鉴的是谁就不知道了

    相关提案在这里
    https://github.com/tc39/proposal-optional-chaining
    yimity
        2
    yimity  
       2020-09-23 23:22:35 +08:00
    Angular 来源于谁的?
    des
        3
    des  
       2020-09-23 23:24:08 +08:00
    @des
    还有另外一个相关的特性也挺好用的
    https://github.com/tc39/proposal-nullish-coalescing
    ragnaroks
        4
    ragnaroks  
       2020-09-24 09:02:49 +08:00
    只说作用的话,我个人见到最早的是 csharp 的

    "obj1?.method1()"

    "var obj=obj1 ?? obj2"
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3689 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 982ms · UTC 05:03 · PVG 13:03 · LAX 22:03 · JFK 01:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.