ES6 immediately invoked arrow function
Why does this work in a Node.js console (tested in 4.1.1 and 5.3.0) but doesn't work in the browser (tested in Chrome)? This code block should create and invoke an anonymous function that logs Ok . () => { console.log('Ok'); }() Also, while the above works in Node, this does not work: n => { console.log('Ok'); }() Nor this: (n) => { console.log('Ok'); }() What's odd is that when the parameter is added it actually throws a SyntaxError at the immediately-invoking part. void You need to make it a function expression instead of function definition which doesnt need a name and makes it a valid