Skip to content

Type Conversion & Coercion

Programming

Master explicit conversion and implicit coercion rules.

Official Site
01

Overview

Explicit: Number(x), parseInt. Implicit: 5*2===10. Falsy: false,0,empty,null,undefined,NaN. Use === to avoid surprises.

bash
Number("42"); parseInt("42px",10);
"5"+3 // "53"  "5"-3 // 2
02

Best Practices

Use === and !==. Convert explicitly at boundaries. Validate with Number.isFinite. Use TypeScript for safety.

Ready to try Type Conversion & Coercion?

Visit the official site for the latest version and full documentation.

Visit Type Conversion & Coercion