Topic awaiting preservation: parseInt (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: NZ |
posted 08-15-2003 00:04
Q: What is the purpose of using parseInt? Let me explain. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 08-15-2003 02:58
Ah, yes. Well, NaN stands for Not a Number, which means "I couldn't get a number out of this string." You can't safely omit the parseInt, however, because something like this: code: var userinput = parseInt(form.input.value);
code: var userinput = parseInt(form.input.value);
|
Paranoid (IV) Inmate From: NZ |
posted 08-15-2003 04:52
Hi, Slime. quote:
code: var userinput = parseInt(form.input.value);
|
Paranoid (IV) Inmate From: NZ |
posted 08-15-2003 04:57
Yeah, I don't need {}. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 08-15-2003 08:06
Yup, { } is optional for if's, else's, while's, for's, and pretty much everything except for switch's and function's when there's only one statement inside of it. |
Bipolar (III) Inmate From: Belgium |
posted 08-27-2003 13:09
Don't forget the function parseInt() has two arguments! |