Most developers when using HTML inputs with type="number" assume the input value will be a number, and get confused when the value is a string instead. This is because the type=“number” actually tells the browser that the input is used for numbers and to provide a number input UI with included built-in validation to reject non-numerical entries.

Now to get the number almost everyone will use the good old parser functions parseInt/parseFloat, like this:

parseInt(input.value, 10);

But, there is a less-known property called .valueAsNumber which allows us to avoid parseInt/parseFloat functions, for example:


How cool is that!

10:02 (+0200)
Cavallino-Treporti, Italy