parseInt vs Number Playground

Mr. Tono’s rice weigh note read by three people: Mrs. Tini’s parseInt, Rara’s parseFloat and Rizal’s Number. Where does each stop reading, and when does NaN…

Why it matters

Turning text into a number happens in every form, every CSS value, every note from a machine. Pick the wrong one and '12kg' quietly becomes NaN, or dirty input slips through as 12, or an empty note becomes 0.

The key idea

parseInt reads part of it, Number all of it or nothing

Common mistakes

Try it in this playground