Why a value of an input type number is a string and not a number?

Asked

Viewed 158 times

1

I am wrong or if I take with javascript the value of an input type number it will be a string and not a number?

1 answer

1


Because HTML doesn’t have data types. This question of forms having a type is for browsers to work better with the information of each form type.

As for the type number <input type="number" ...>, That’s only for cell phones, smartphones display the number pad at the time of typing.

Everything that comes out of the DOM is mapped as string.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.