Coercion in Javascript

Mallet smshing an egg

Day 3: Coercion

To oversimplify this is the act of converting a value from one type to another. An array to a number, a string to an boolean etc.

var a = 42;
var b = a + ""; // implicit coercion
var c = String( a ); // explicit coercion

You Don’t Know JS

Author: Joseph Dickson

Joseph Dickson is a front-end web developer with experience building higher education websites using Drupal and WordPress.