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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.