isNaN() [FF, IE 4]
Returns true
if the parameter is not a number, false
otherwise. Example:
var zip_code = "none of your business"; if (isNaN(zip_code)) { alert("Please provide something that at least looks like a zip code!"); }
Since zip_code
contains a string, isNaN()
returns true
, triggering the alert.
Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.