Skip to content

Pre defined Functions

Lev Brie edited this page Jan 28, 2015 · 4 revisions

Pre-defined Functions

JavaScript has a number of useful built-in functions. Of these, the eval() function should be avoided when possible:

Function Purpose
parseInt() takes any input, tries to make an integer, returns NaN on failure, takes radix as second param
parseFloat() same but for floats
isNaN() checks if a number is NaN, since NaN is of type number and is not equal to itself
isFinite() number that is neither Infinity nor NaN
encodeURI() escape special characters in URLs and URIs, returns a usable URL
decodeURI() unescape escaped characters in URLs
encodeURIComponent() like encodeURI() but used with only part of a URL (the part to be encoded)
decoreURIComponent() ditto
eval() executes a string input as JavaScript code - this function is both dangerous and bad for performance and should usually be avoided
Clone this wiki locally