stx0821
V2EX  ›  问与答

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

  •  
  •   stx0821 · Sep 23, 2020 · 1520 views
    This topic created in 2071 days ago, the information mentioned may be changed or developed.
    des
        1
    des  
       Sep 23, 2020
    我记得有好几个语言支持这种操作,比如 ruby:account&.owner&.address
    swifter 也是用"?"的,借鉴的是谁就不知道了

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

    "obj1?.method1()"

    "var obj=obj1 ?? obj2"
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   923 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 21:26 · PVG 05:26 · LAX 14:26 · JFK 17:26
    ♥ Do have faith in what you're doing.