search

Home  >  Q&A  >  body text

Javascript's () => syntax

I just learned javascript and node.js. When I was studying an example, I found the following writing method, but webstorm directly marked the error and displayed expression expected. What is going on?

'use strict';

const fs = require('fs');

console.log('script start');    

const interval = setInterval(() => {
        console.log('setInterval')
}, 500);
phpcn_u1582phpcn_u15822756 days ago658

reply all(4)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-19 10:41:59

    () => {}This is the arrow function of ES6. Set webstorm to support ES6.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-19 10:41:59

    Change the configuration. I am using PhpStrom, but it should be similar.

    reply
    0
  • PHPz

    PHPz2017-05-19 10:41:59

    =>Arrow function, introduced here:
    Arrow function

    Switch on webstorm中需要打开ES6:

    Settings -> Language & Framework -> JavaScript -> Set the right side to ECMAScript6

    reply
    0
  • ringa_lee

    ringa_lee2017-05-19 10:41:59

    Lambda expression is only supported by es6

    reply
    0
  • Cancelreply