Value vs Reference Assignment in JavaScript

In my opinion, value vs reference assignment is an important topic that many JS beginners don’t stop and think about enough.

Let’s test your knowledge of this concept with some puzzles.

Puzzle #1:

This first puzzle is part of Douglas Crockford’s function challenges. You can watch some of his exercises in the free video sample at FrontEndMasters.

What is x?

function funky(o) { o = null; } var x = []; funky(x); alert(x);

o is a parameter …

Read Article

Type Checking in JavaScript

At first, type checking may seem like a straightforward concept. A value can either be an object, a function, an array, a number, a string, a boolean, null, or undefined. JavaScript has the typeof operator which returns a string indicating the type of the operand.

typeof 5 === 'number' // true 

Easy as pie, right? Unfortunately, typeof is not as reliable as you might think.

What does the following equal?

typeof NaN 

If you …

Read Article