String functions
Provides a reference of string functions.
| Syntax | Effect |
|---|---|
| String.fromCharCode(code) | Returns a single-character string containing the character with the given ASCII code. Examples: String.fromCharCode(65) –>"A" writeln(String.fromCharCode(0x30)); –> "0" |
| parseInt(string [ , base ] ) | Parses string as an integer written in the given base, and returns its value. If the string does not represent a valid integer, NaN is returned. Leading white space characters are ignored.
If If Examples: parseInt("123") –> 123 parseInt("-123") –> -123 parseInt("123.45") –> 123 parseInt("1001010010110", 2) –> 4758 parseInt("a9", 16) –> 169 parseInt("0xa9") –> 169 parseInt("010") –> 8 parseInt("123 poodles") –> 123 parseInt("a lot of poodles") –> NaN |
| parseFloat(string) | Parses string as a floating-point number and return its value. If the string does not represent a valid number, NaN is returned. Leading white space characters are ignored. The string is parsed up to the first unrecognized character. If no number is recognized, the function returns NaN. Examples: parseFloat("-3.14e-15") –> -3.14e-15 parseFloat("-3.14e-15 poodles") –> -3.14e-15 parseFloat("a fraction of a poodle") –> NaN |