TIL: Arrow Function

Feb 9th, 2017 #TIL, JavaScript Kerry 2 min read

TIL that the arrow function introduced in ES6/2015 is NOT just short-hand for a normal function declaration. It uses lexical this scoping rather than the dynamic. Kyle Simpson argues in his excellent series You Don’t Know JavaScript that this was created in part because people misunderstand how this works and how to utilize bind. Take the following example:

The above function’s setTimeout call-site is the global scope. This…

TIL: Hoisting

Feb 9th, 2017 #TIL, JavaScript Kerry 1 min read

Today’s nugget of information is brought to you by McDonald’s 6-piece Chicken McNuggets. Hoisting in JavaScript is when the compiler performs all declarations at the beginning of a scope. TIL that the following single line of code is interpreted by the compiler as two lines:

This is why functions created by variable assignments cannot be used prior to assignment unlike regular function declarations, i.e.

Inaugural TIL

Feb 7th, 2017 #TIL, JavaScript Kerry 1 min read

TIL stands for Today I Learned. Starting today, I’ll be posting daily about one thing I learned related to web/game development and engineering. My way of trying to aspire to freeCodeCamp’s #100DaysOfCode challenge. To kick things off, today I learned that in Javascript, if not in strict mode, making an assignment to an undeclared variable, no matter how nested the scope, will result in the variable being…