paint-brush
Javascript ES6 — Arrow Functions and Lexical `this`by@_bengarrison
100,859 reads
100,859 reads

Javascript ES6 — Arrow Functions and Lexical `this`

by Ben Garrison2mAugust 19th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

<span>O</span>ne of the most anticipated new features in the ES6 Javascript standard was the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions" target="_blank">Arrow Function Expression</a>. It promises a <a href="https://www.sitepoint.com/es6-arrow-functions-new-fat-concise-syntax-javascript/" target="_blank">shorter syntax</a> than it’s predecessor the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function" target="_blank">Function Expression</a>. In addition(and IMHO more exciting) is how the new Arrow Function binds, or actually <strong>DOES NOT</strong> bind it’s own <code class="markup--code markup--p-code">this</code><em>. </em>Arrow Functions <strong>lexically</strong> bind their context so <code class="markup--code markup--p-code">this</code> actually refers to the originating context.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Javascript ES6 — Arrow Functions and Lexical `this`
Ben Garrison HackerNoon profile picture
Ben Garrison

Ben Garrison

@_bengarrison

L O A D I N G
. . . comments & more!

About Author

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite