Web APIs
HTMLInputElement.valueAsNumber
Numeric representation of the current value for supported input types; NaN when no numeric conversion is possible.
Formal Syntax & Structure
javascript syntaxjavascript
input.valueAsNumberReturn Value
number
Numeric value or NaN.
Working Example
Example Snippetjavascript
const i=document.createElement("input");i.type="number";i.value="12";console.log(typeof i.value,i.valueAsNumber);i.value="";console.log(Number.isNaN(i.valueAsNumber));