My Favorite Book on JavaScript

My first degree from college was a BA in English. The only reason I mention this is to point out that I love to read and that I can sometimes be overly critical of certain books. Because I love to read, I have purchased numerous books on JavaScript.

I’m very analytical about the books I purchase. I won’t buy just any book on JavaScript. But despite that, as I take a quick look at my library, I have over a dozen books just on JavaScript. That doesn’t even include the books on various frameworks and libraries.

So which book is my favorite? Without any further ado, here it is:

This book serves two purposes for me. It acts as a reference which I use several times a week for that purpose. The index is well done, which is necessary for a reference book. Second, it also works quite well as an instructional tool. If there is something in JavaScript I am not familiar with, I can always turn to this book for an explanation of how it works or how to use it.

The book is divided into two main parts: Core JavaScript and Client-Side JavaScript. I like this approach. It sends the message that JavaScript is not just for the browser. However, there are several important nuances when using JavaScript in the browser that are covered thoroughly in the section on Client-Side JavaScript.

This book is nothing if not thorough. I can always find what I am looking for. Want to get an intro to Node or jQuery? It is in there. Want to find out about modules. It is in there. Hoping to understand closures better? It is in there. Or maybe you simply want to know the primitive values in JavaScript. It is all in there. From the simple to the complex, this book has something to say about each topic.

This book is probably not the most exciting book I have on JavaScript. Nor is it the most interesting to read. It is probably not the book that has expanded my thinking the most about JavaScript. But it is the book I always turn to. It is the only book I have purchased twice. I originally bought the 4th edition, and then a couple years back upgraded to the 6th edition.

If you don’t have this book, you may want to add it to your library or use it to start your JavaScript library: JavaScript: The Definitive Guide.

The Difference Between let and var

JavaScript traditionally has had two types of scope: global scope and function scope. Global scope allows you to access variables from anywhere in the program. But it can be dangerous in large programs. Your global scope can become messy and you risk accidentally overwriting values that you did not intend to overwrite.

Function scope is the preferred scope method to use and there are a number of JavaScript patterns to help avoid defining things in the global scope and to take advantage of functional scope.

With ES6/ES2015 we now have the ability to define block scope: restricting the scope of a variable to a block of code. This is done with the let keyword. Its most common application seems to be in for loops, though there are numerous other applications. The pure nature of the counter variable in a for loop, lends itself to block scope.

for (let i = 0; i < 10; i++) {
console.log(i);
}

The variable i is only needed during the existence of the for loop, that particular block of code. Therefore, why define it with var and extend its scope.

In this tutorial we explore the difference between var and let. Enjoy watching and happy coding!

Trying Out Thimble by Mozilla

A couple of weeks ago I first learned about Thimble while reading one of the several newsletters I receive each week. Quoting directly from the Thimble web site, it is an online code editor that makes it easy to create and publish your own web pages while learning HTML, CSS & JavaScript.

The tool seems to be designed for younger kids, but it looks helpful to anyone that is just starting in web development and needs to learn HTML, CSS. You can view a quick introduction video, create an account and get started by visiting the Thimble web site.

Here are a list of features that Thimble offers:

  • You can start a new web page by copying an existing web page. This is called remixing in Thimble. This is a great option for beginners. You get to see the HTML, CSS and JavaScript, make tweaks and see how those tweaks change the site. If you choose to, you can also start a web page from scratch.
  • The Thimble editor consists of three areas: a file manager, a code editor and a preview pane. This allows for ultimate flexibility as you try out different things. You can add additional pages via the file manager. You can then build or edit pages using the code editor. When you make changes in the code editor, those changes automatically show up in the preview pane.
  • Assistance features are provided to help you learn. For example, you can highlight a CSS attribute or an HTML tag, press Alt+k and the code editor will display a description of the tag or CSS attribute. I tried to do this with JavaScript reserved words, but it didn’t seem to work.
  • Some projects have a tutorial file that walk you through a short tutorial different techniques for that site.
  • Once you have created a site, you can publish it to the web. You are provided with a URL that you can share with others. This is a great option for younger learners.

Go ahead and give Thimble a try and see if it is the type of tool that could aid in your web development learning.

Demystifying JavaScript Closure

Closure seems to be one of those concepts in JavaScript that can be a bit mysterious. However, the funny thing about closure is that many JavaScript developers take advantage of it before they understand what it really is. So is it necessary to understand closure?

I think it is. If you understand the concept, then you are able to take advantage of what it offers. You will find more programming situations where you can apply closure.

Here is my favorite definition of closure. This comes from one of Kyle Simpson’s books:

You Don’t Know JS: Scope & Closures

Closure is when a function is able to remember and access its lexical scope even when that function is executing outside its lexical scope.

Now the only problem with this definition is that you need to understand lexical scope. Think of it this way. When you write a program, you place a function inside a particular scope based upon where you enter that function. That is the function’s lexical scope.

Keep this in mind as you take a look at this tutorial on closure. It will explain it, present several examples and illustrate the power of closure. Happy viewing!

Some Interesting Data from the State of JavaScript Survey

The State of JavaScript survey has recently been released and shows some interesting data points. I hope this is the first iteration of many to come for this survey as I found some interesting information. You can access the survey and sign up to be included in next years survey by going to stateofjs.com.

Here are some of the data points that I found most interesting.

In the front-end frameworks section, I was amazed at the popularity and interest in React. I first looked at React a few weeks ago and was quite impressed myself. It seems that there are many others in the JavaScript world that are feeling the same way. Time to get to know React better.

Another surprise for me was the build tools category. Though not the top performer, Gulp did very well. I personally prefer Gulp and hence the interest. I always thought of it as a poor runner-up to Grunt, but it seems to fair much better than that.

The Opinions section was also quite interesting. Many agree that the JavaScript world is way to complex and changing too fast. However, what I found as an interesting twist is that many are happy with the direction JavaScript is headed.

Take a look at the report as there are many more categories than those mentioned here. I’m sure you will find some surprising results as well.

Thoughts on How to Learn JavaScript

The JavaScript landscape can be very confusing. It seems every week there is a new framework or library being released. It can be very difficult keeping up on the latest.

So if you are just starting your journey down the JavaScript highway, you may be asking yourself which direction do I take? How fast should I travel? What automobile should I drive?

In this first tutorial published at All Things JavaScript, we address the question of how to go about learning JavaScript. I believe you will find the guidance helpful as you plan your trip.

For additional tutorials you can subscribe to the YouTube channel here.

Welcome to All Things JavaScript

banner

Welcome to the All Things JavaScript tutorial blog. I’m excited about the future of All Things JavaScript, and just wanted to take a few minutes to explain the motivation behind this site.

I’ve been involved with JavaScript for many years now, but have recently become very interested in the power of the language and how it is being taught. I feel there is still too much JavaScript being written that relies on pre ES5 capabilities. There is so much being done with JavaScript and its more modern capabilities, and those things are exciting.

So why is there still so much old JavaScript code being written? Well, I think there are at least two reasons:

  1. It is easy to do.
  2. Those learning JavaScript are not learning its full capabilities.

Well, there is not much I can do about number 1. But I feel that at All Things JavaScript, we can do a much better job at number 2. I’ve always had a passion for teaching and I feel I do fairly well at it, so I decided to apply that to JavaScript. New learners of JavaScript need to learn all that it is capable of, and their education shouldn’t be short circuited by the need to get a job done. That is how I first learned JavaScript and it was a disservice to me. For that reason we are creating courses to “teach JavaScript the right way”. You can access those courses here.

Second, I feel we can provide resources in the form of tutorial videos and blog posts that can help those in the JavaScript world. That is the purpose of this area of the website. We will link to some of our favorite YouTube videos and provide other information that the JavaScript world may find helpful. If you would like to subscribe to our YouTube channel, you can do that here.

We hope you will find this site useful and that you will visit us often.