Do I Use undefined or null?

JavaScript provides two ways to indicate an absence of value: undefined and null. I can remember writing if statements like this in order to test for a value:

if (val !== undefined && val !== null && val !== “”) {

Basically, I was just grabbing at straws. I didn’t know what the value would be if it didn’t have a value, so I was covering all bases.

Well, it is obviously better to work from a position of knowledge. Therefore, it is important to understand the difference between undefined and null. Why are there two ways to indicate an absence of value? Should you ever set something to undefined? What situations cause undefined? What situations cause null?

All these questions are addressed in our latest JavaScript Questions tutorial: What is the Best Way to Work with undefined? Make some popcorn, click on the video and enjoy.

How Do You Know if Someone is an Expert in JavaScript?

I love this type of question! Not so much because I want to find out if I am an expert. It is mainly because I love to read the answers that people post to this type of question.

Obviously the posts will reflect what that person sees as important. I find this very helpful because I can then evaluate whether that is a strength of mine or not. If it is not a strength, I can look to learn more in that area.

This question was recent posted on Quora, and I found the responses interesting. In some cases it caused me to think about whether that skill is really important or not. But most of the time I agreed and mentally marked topics that are important to understand in JavaScript.

What skills do you think make someone an expert JavaScript programmer?

If you want to read the original post go here.

What is Type Coercion?

JavaScript is very forgiving when it comes to working with different data types. Most languages generate an error if you try to perform an operation that uses two different types. But not so in JavaScript. This is because of type coercion.

JavaScript attempts to convert one type to another in order to complete the operation. There are some advantages to this feature of JavaScript, but it can also cause a lot of headaches.

In our most recent tutorial on our YouTube channel, I address type coercion and some of the difficulties you can encounter. This is a concept that is important to understand if only so you can avoid some of the problems it can cause.

Take a view and see what you think.

Six JavaScript Concepts to Learn Thoroughly

In this post I wanted to address a topic I have been thinking about lately.

A lot of JavaScript developers are self taught. That is how I learned JavaScript initially. But as I have thought back on that process, I have realized I missed some very important concepts. These concepts have made a huge difference in my JavaScript abilities since learning them, so I thought I would address what I feel are six JavaScript concepts you should understand well, but might have been missed. Everyone seems to learn the elements of the language, but sometimes these concepts are missed in that process.

Here are the six concepts:

  • Coercion
  • Scope
  • The True Nature of Objects
  • this
  • The Power of Functions
  • The Namespace / Module Pattern

Though a simple idea coercion can mess you up or help you out if you understand how it works. In certain operations JavaScript will attempt to coerce one data type to another. The equality operators are perfect examples of this. Basically a good rule is that you should use triple equality unless you have a reason to use double equality. And the only way you would know that you have a reason to use double equality is if you understand coercion. So coercion is the first concept.


Scope is important to understand in any language, but it sometimes gets neglected. Scope defines where identifiers (variables and functions) are accessible. JavaScript uses function scope; meaning that scope is established by functions. In ES6/EcmaScript 2015 block-scope was introduced with the let and const keywords. So Scope is the second concept that I feel is important to understand thoroughly.

The True Nature of Objects

Objects are at the heart of JavaScript, and to take full advantage of what JavaScript offers you need to understand them. Most important is to understand the concept of prototypes and prototypal inheritance. Even if you use a psuedo class structure to create objects like constructors or the new ES6 class definition, you still need to understand prototypal inheritance. That is concept three.


The fourth concept that is the this keyword. The this keyword can sometimes seem almost mystical in JavaScript. It is important to understand that this is a binding that happens when a function is invoked and the object that the this keyword references depends on how the function is invoked. Understanding these different situations is the way to understand the this keyword in JavaScript.

The Power of Functions

Now if objects are the heart of JavaScript, the power of JavaScript are functions. In JavaScript, Functions are objects and are considered fist class. This means that function can be passed around and returned from other functions. This is a powerful feature of JavaScript. To take full advantage of functions you need to understand this feature.

An important concept that revolves around functions is closure. Closure is key to taking advantage of the power of functions. And to go with that, an important construct to grasp are Immediately Invoked Function Expressions.

The Namespace / Module Pattern

Finally, the sixth concept is not really a JavaScript concept, but more of a programming pattern. But I feel the pattern is important enough to include. That is the Namespace or Module pattern. These patterns are closely related and are found in all serious development projects. There are multiple variations on the patterns, but you should be using some form of these patterns in your projects.


Now I purposely have not gone into any depth about any concept. Each concept requires one or more tutorials. My goal was to identify them as important to any JavaScript developer.

There are a number of resources if you want to learn more. Our Learn Modern JavaScript courses spend a good deal of time on these topics and numerous other topics. We have also included tutorials about some of these topics.

What do you think about the six concepts? What would you add? Subtract?