Does node.js support the 'let' statement?

后端 未结 5 1933
别那么骄傲
别那么骄傲 2020-12-01 09:03

Does node.js support a let statement something like what\'s described on MDN??

var x = 8,
    y = 12;

let ( x = 5, y = 10) {
    return x + y;
} //15
         


        
5条回答
  •  既然无缘
    2020-12-01 09:51

    You can use the Babel transpiler and use let as well as many other ES6/ES2015 features.

    To use babel:

    $ npm install --save-dev babel
    

    Then in your package.json:

    "scripts": {
      "start": "babel-node index.js"
    }
    

    Inside index.js:

    let foo  = 'bar;
    

    Then start the server:

    $ npm start
    

提交回复
热议问题