bhylu.com

Advertisements

JS Type Coercion

Some operators convert types automatically. Read the operands before assuming plus will perform arithmetic.

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.

A practical example

JavaScript

console.log("6" + 2);
console.log("6" - 2);

What happens

The outputs are the string 62 and the number 4.