search

Home  >  Q&A  >  body text

es6 Null conduction operator - es6 Null conduction operator

How to use the Null conduction operator in Ruan Yifeng es6.

const firstName = message?.body?.user?.firstName || 'default';

写了这句之后直接编译出错了。

某草草某草草2774 days ago1659

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-05-19 10:32:39

    This syntax is js 的么?感觉是 coffee 的,即使 js 有,应该也得有引入对应的presetsbabeles6好像没有这种语法,引入最新的babel presetTry to see if it can be compiled

    reply
    0
  • PHPz

    PHPz2017-05-19 10:32:39

    Mentioned in the article. "Null Conduction Talisman" is just a proposal. Babel is not displayed yet.

    reply
    0
  • Cancelreply