Strings

  • String elements are zero-based.
  • Strings are objects.
  • String literals can be delimited by single or double quotes.
  • String literals are automatically converted to objects.

Properties


length
  • The number of characters in the string.

Methods


charAt(index)
  • Returns the character at the specified index.
indexOf(search-str)
  • Returns the index number of the first occurrence of the search string (searches from left to right), or -1 if the string is not found.
lastIndexOf(search-str)
  • Returns the index number of the last occurrence of the search string (searches from right to left), or -1 if the string is not found.
substring(start-index [, end-index])
  • Returns a substring, up to but not including end-index; the indexes do not have to be in numerical order.
toLowerCase()
toUpperCase()

Escape characters

\b    Backspace
\f Form feed
\n New line
\r Carriage return
\t Tab
\' Apostrophe or single quote
\" Double quote
\ Backslash