ES6 Arrow functions

Last night I was reading this post: ES6 arrow functions, syntax and lexical scoping and going through the comments I saw this question: so arrow functions always inherit scope? The answer was by Barney: always. I went to the console and typed: nvm use 4 node var doSome = () => { console.log(this.x) } doSome.call({x: ‘hello’}); global.x = ‘hello’; doSome.call({x: ‘good bye’}); Could you guess what is going to be printed?
Continue reading

Author's picture

Hector Yeomans

Senior Software Engineer

Principal Engineer @ Roblox

California