JavaScript Commands

The String Object

Command Definition
charAt(x) returns the character of a string at position x where x is a number. The first index of a string is 0.
charCodeAt(x) returns the ANSI code of the character of a string at position x where x is a number. The first index of a string is 0.
fromCharCodeAt(x,y,z) pass this function a series of comma separated numbers that represent ANSI characters and it will create a string of them.
Example: foo = String.fromCharCodeAt(65,66,67); will give foo = "ABC".
indexOf("foo") returns the position of the string foo in a larger string. The position of the first character in a string is 0. If the string is not found, it returns -1.
lastIndexOf("foo") same as the above except the code searches the string starting at the end of the string. If the string is not found it retunrs -1.
substr(x,y) will cut out part of a string. The cut begins at character x and will have length y.
substring(x,y) will cut out part of a string. The cut string begins at position x and ends at position y-1.
toLowerCase() changes all alphabetical characters in a string to lowercase. Does not effect other characters.
toUpperCase() changes all alphabetical characters in a string to uppercase. Does not effect other characters.
split("x") Splits a string at the character x and returns the parts as an array.
replace("test", "foo") Replaces all occurences of test with foo in a string. For example, newstring = oldstring.replace("test", "foo") will give newstring a copy of oldstring except with the new replacesment(s). The value of oldstring, however, remains unchanged.
search("foo") Searches for a particular string and returns the character position where it begins. If the string is not found, -1 is returned.
match("foo") Matches the substring in a larger string and returns an array with the substing as it's elements. The returned array has an element of the substring for each occurence of the substing.
test()

The Array Object

Command Definition
concat("foo") Will concatonate one array onto another. For example,
newarray = array1.concat(array2); will make a new array of array1 + array2.
slice(x,y) will cut out part of an array from x through y-1 and put them into a new array.
join("x") will join an array into a string where the elements will be separated by the character(s) x (such as a comma).
sort() Will sort an array into ANSI order.
reverse() reverses the order of the array.

The Math Object

Command Definition
abs()
ceil()
floor()
round()
random()
pow()

The Date Object

Command Definition
Hosted by www.Geocities.ws

1