JavaScript week #2: YDKJS notes

We have started a book club in the dev team at Clearleft and our first read is You Don't Know JS: Up & Going, the first of five books in a series by Kyle Simpson. Our plan is to read a chapter each week and discuss it on the Monday. Last week we read chapter 1: Into Programming.

It can be tempting to skip over the introductions of books when you think you already know the basics, but don't do it! The fundamentals are very important. Whilst I had seen and used most of the basics before, the chapter was really valuable for learning about the terminology which helped me better understand some of the functions, expressions, values, loops, etc that I use every day. Improving my understanding also helps me get better at describing my code to others.

Some useful terminology I noted from the book:

  • The for loop has three clauses: the initialization clause (var i=0), the conditional test clause (i <= 9), and the update clause (i = i + 1)
  • Converting between value types is called "coercion".
  • Equals operators: = assignment, == the same meaning but not exactly the same (e.g. 0 and false), === literally exactly the same value.
  • Every function gets its own scope. According to the book, Scope is basically a collection of variables as well as the rules for how those variables are accessed by name. Only code inside that function can access that function's variables.
  • In a do while loop the conditional is tested after the first iteration.

There's lots more great content in the chapter, but these were most interesting to me. I'm looking forward to reading Chapter two this week.

Tags: