Mallet smshing an egg

Coercion in Javascript

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





Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.