rs79.vrx.palo-alto.ca.us

JavaScript String Functions
JavaScript String Functions

    Note: square brackets denote [Optional] arguments.

  1. charAt(n) - Returns the n'th character of the string.
    Ex., if var str = "abcde"; then str.charAt(3) would be d

  2. charCodeAt(n) - Returns the Unicode value of the n'th character of the string.

  3. concat(v1, v2,…) - Returns the concatenation of the strings given as arguments.

  4. fromCharCode(c1, c2,…) - Returns a string made up of the unicode characters given as arguments..

  5. indexOf(substr, [start]) - Returns -1 or index of substr in string.
    Ex., if var foo = "abcdef"; then foo.indexOf ("cd") would return 2. Or -1 if not found.

  6. lastIndexOf(substr, [start]) - Same as above but start at the end of the string.

  7. match(regexp) - Returns array of information or null if not found.

  8. replace(regexp/substr, replacetext) - Searches and replaces regexp/substr with replacetext.

  9. search(regexp) - Returns index to regexp or null if not found.

  10. slice(start, [end]) - returns a substring from start to the end of the string or up to but not including the optional end

  11. split(delimiter, [limit]) - Splits a string into many according to the specified delimiter, and returns an array containing each element. The optional “limit” is an integer that lets you specify the maximum number of elements to return.

  12. substr(start, [length]) - Returns the characters in a string beginning at “start” and through the specified number of characters, “length”. “Length” is optional, and if omitted, up to the end of the string is assumed.

  13. substring(from, [to]) - Returns the characters in a string between “from” and “to” indexes, NOT including “to” itself. “To” is optional, and if omitted, up to the end of the string is assumed.

  14. toUpperCase() - Returns the string with all of its characters converted to uppercase.

  15. toLowerCase() - Returns the string with all of its characters converted to lowercase.