Table of contents Home page
Execute this code
// Parsing stops when a character is encountered that cannot be interpreted as a valid part of a number // so, the part after "5.5" will be ignored. // And since the method can only convert strings to integer numbers, the fractional part is also ignored. var n = "5.3 m" alert("5.3 m × 3 ≈ " + 3 * parseInt(n) + " m.") // The method can also convert strings that represent numbers in the heaxadecimal 0x notation. n = "0Xa" alert(n + " = " + parseInt(n)) // The string can in no way be interpreted as a valid number, so this time the method returns NaN. n = "five" alert(parseInt(n))