AJAX - The Complete Reference

(avery) #1

PART IV


Appendix A: JavaScript Quick Reference 563


NNOTEOT E While encodeURIComponent() and escape() are commonly deemed useful for preparing
data for Ajax-based transmission, neither works properly for true x-www-urlencoded
formatting. See Chapter 4 for more details on the absolute method for correct encoding.

Array Literals
JavaScript supports arrays both in an object and literal style. Array literals are used with the
following syntax (the brackets are “real” brackets and do not indicate optional components):

[element1, element2, ... elementN]

Each elementN is optional, so you can use an array with “holes” in it, for example:

var myArray = ["some data", , 3.14, true ];

Property Description
decodeURI(encodedURI) URI-decodes the string encodedURI and returns the
result
decodeURIComponent(uriComponent) URI-decodes the encodeURIComponent-encoded
string uriComponent and returns the result
encodeURI(string) URI-encodes the string string and returns the result

encodeURIComponent(string) URI-encodes the string string and returns the result
escape(string) URL-encodes string and returns the result
eval(x) Executes the string x as if it were JavaScript source code

Infinity The special numeric value Infinity
isFinite(x) Returns a Boolean indicating whether x is finite (or
results in a finite value when converted to a number)
isNaN(x) Returns a Boolean indicating whether x is NaN (or
results in NaN when converted to a number)
NaN The special numeric value NaN
parseInt(string [, base]) Parses string as a base-base number (10 is the default
unless string begins with “0x”) and returns the primitive
number result (or NaN if it fails)
parseFloat(string) Parses string as a floating point number and returns the
primitive number result (or NaN if it fails)
undefined Value corresponding to the primitive undefined value
(this value is provided through Global because there is
no undefined keyword)
unescape(string) URL-decodes string and returns the result

TABLE A-9 Properties of the Global Object
Free download pdf