Thoughts #1: JavaScript Scope & Hoisting

I am in my very early stage of JS learning and just beginning to get used to and familiarize myself with the fundamentals of the the JS language. Last week, I spend lot of time understanding the basic JS function (declaration, expression, arrow functions) and write my learning-note about it. I have had already my share of many many frustrating moments to understand other JS topics clearly. After spending almost a week, I am still confused. The topic is not straight forward but confusing.

And don’t think everything will become totally logical: JavaScript is confusing.

Callback Function

While learning functions, I came across yet another function – callback function. I spend some time learning about it and realized that it could be confusing to newbie like me. Nevertheless, I wrote a learning-note about callback function too.

Function Declaration vs Function Expression

Before I move on to other topics (eg. Objects), I opted to devote some time to understand the difference between function declaration & function expression. After learning basic difference in syntax, I started getting confused with conditionally created functions. To better understand this concept, basic knowledge of variable hoisting with var, let and const and var/function scope is essential.

Scope & Hoisting

While learning functions (declaration & expression) and variables but I get confused when I start trying to untangle scope (variable & function), hoisting. My plan for next week or so is to understand variables ( var, let & const) and Function Scopes & closures.

Waiting for My “Ah ha” Moment in JS Functions

Finally, I did some goggling to learn how other JS developers with similar to mine non-programmer background overcome their most frustrating learning experience. In a 2012 CSS-Tricks forum post Chris  Coyier  sought inputs from his site’s participant to share their The  JavaScipt “Ah ha!” Moment.  Most forum participant commented that understanding of closure, scope, hoisting, objects made them feel their “Ah ha” moment. From their comments, I recognized that JS Closure & Scope were the most frequently mentioned confusing topics to understand.

JavaScript is a confusing language to learn. I am Still Waiting for My ‘Ah ha’ moments in JS Function (scope, hoisting)

In a more recent post in Medium Tan Moy (Web Developer / Data Scientist) wrote that his Aha! Moments in JavaScript was JS Callbacks.

Book Recommendation

Tom McFarlin (WordPress developer) writes that JavaScript: The Good Parts (O’Reilly Publication) solidified his understanding of the JavaScript language.

Useful Resources

The following resources appear to be relevant to further review these topics: