Javascript's () => syntax
phpcn_u1582
phpcn_u1582 2017-05-19 10:39:59
0
4
679

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_u1582
phpcn_u1582

reply all(4)
淡淡烟草味

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

我想大声告诉你

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

PHPzhong

=>Arrow function, introduced here:
Arrow function

Switch on webstorm中需要打开ES6:

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

左手右手慢动作

Lambda expression is only supported by es6

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template