Basic Functions

Loading...

Overview

See MDN 'Function properties'

isFinite()

Returns false if the argument is NaN, positive infinity or negative infinity.

isFinite(testValue)

isNaN()

Returns true if the argument, when coerced to a numeric value, is an IEEE-754 'Not A Number' value.

isNaN(testValue) Note: Using isaNum(x), which is the inverse of isNaN(x) and is used to avoid the confusion of double-negatives. Note: Using isaNum(x), which is the inverse of isNaN(x) and is used to avoid the confusion of double-negatives.

parseInt()

Parses a string up to the first non-digit character (whereas the Number() function parses the entire string as a number).

See What's the difference between parseInt and Number?

parseInt(string, radix)

parseFloat()

Parses a string up to the first non-digit character (whereas the Number() function parses the entire string as a float).

parseInt(string, radix)

encodeURI()

Encodes the entire URI, preserving special chars required for GET and POST requests (e.g., "&" and "="). To encode user entered data, that could contain these chars, use encodeURIComponent() on each component of user data making up the URI.

encodeURI(uri)

encodeURIComponent()

Encodes user data, used as a component of a URI.

encodeURIComponent(userStr)

decodeURIComponent()

decodeURIComponent(encodedUserData)