Book Image

Object-Oriented JavaScript

Book Image

Object-Oriented JavaScript

Overview of this book

Table of Contents (18 chapters)
Object-Oriented JavaScript
Credits
About the Author
About the Reviewers
Preface
Built-in Functions
Regular Expressions
Index

Pre-defined Functions


There are a number of functions that are built into the JavaScript engine and available for you to use. Let's take a look at them. While doing so, you'll have a chance to experiment with functions, their parameters and return values , and become comfortable in working with them. The list of the built-in functions is:

  • parseInt()

  • parseFloat()

  • isNaN()

  • isFinite()

  • encodeURI()

  • decodeURI()

  • encodeURIComponent()

  • decodeURIComponent()

  • eval()

Tip

The Black Box Function

Often, when you invoke functions, your program doesn't need to know how these functions work internally. You can think of a function as a black box: you give it some values (as input parameters) and then you take the output result it returns. This is true for any function—one that's built into the JavaScript engine, one that you create, or one that a co-worker or someone else created.

parseInt()

parseInt() takes any type of input (most often a string) and tries to make an integer out of it. If it fails...