Appendix B. Built-in Functions

This Appendix contains a list of the built-in functions (methods of the global object), discussed in Chapter 3.

Function

Description

parseInt()

Takes two parameters: an input object and radix; then tries to return an integer representation of the input. Doesn't handle exponents in the input. The default radix is 10 (a decimal number). Returns NaN on failure. Omitting the radix may lead to unexpected results (for example for inputs such as 08), so it's best to always specify it.

>>> parseInt('10e+3')

10

>>> parseInt('FF')

NaN

>>> parseInt('FF', 16)

255

parseFloat()

Takes a parameter and tries to return a floating-point number representation of it. Understands exponents in the input.

>>> parseFloat('10e+3') ...

Get Object-Oriented JavaScript 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.