20.6. Built-in Functions
JavaScript provides a few built-in functions for data manipulation. Most of the built-in functions exist to convert data between the various data types and to check if data is of a particular type. The following table lists the supported functions:
Function | Use | Returns |
---|---|---|
escape | Creates portable data — typically used to encode URLs and other information that may, but generally should not, include extended characters. Extended characters (non-alphanumeric) are replaced by their ASCII number equivalent in hexadecimal %xx form. For example, a space (ASCII 32) becomes %20. | Encoded version of supplied argument. |
eval | Parses the supplied string for JavaScript code and executes the code if found. | The value of the last valid statement or expression encountered in the supplied argument. |
isFinite | Tests an expression or variable to see if it is a valid number. | True if the supplied argument is a valid number, false if the supplied argument is not a valid number. |
isNaN | Tests an expression or variable to see if it is not a (valid) number. | Returns true if the argument is not a number and false if the argument is a number. |
number | Converts an object (typically string data) to a number. | Returns the supplied argument converted to a number or the value NaN (not a number) if the argument cannot be converted to a valid number. |
parseFloat | Parses the given argument for a valid floating-point number. Parsing begins with the first character and ends with the first character that cannot be converted. ... |
Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP 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.