bhylu.com

Advertisements

JS Quiz

Predict the output and explain the type of each result. A type conversion can change both arithmetic and comparison behaviour.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

Before you run it

Write down the result you expect and explain which line produces it. Then run the example and compare your reasoning with the result below.

A practical example

JavaScript

console.log("3" + 2);
console.log(Number("3") + 2);
console.log(3 === "3");

What happens

The results are the string 32, the number 5, and false.