1. Computing & Technology

JavaScript By Example - Functions

These functions are built into JavaScript to make it easier (and in some cases possible) to perform those tasks.

Functions: 1. parseInt

The global parseInt function makes it easy to convert numbers to base 10 from any other number base.

Functions: 2. parseFloat

This function converts text strings to floating point numbers making it easy to define very large and very small numbers.

Functions: 3. isNaN

This function provides a means of testing whether JavaScript considers a value to be capable of processing as a number or not. It returns true if the value is not a number.

Functions: 4. isFinite

This function tests both that the value is a number and also that the number isn't too big for processing.

Functions: 5. encodeURI and decodeURI

These functions 'escape' those characters that could lead to content being misinterpreted and help keep it separate from the surrounding content.

Functions: 6. setTimeout

This function allows you to specify a delay before running a function.

Functions: 7. setInterval

This function looks the same as setTimeout but instead of running the function once, it runs it over and over with the specified interval in between.

©2012 About.com. All rights reserved.

A part of The New York Times Company.