Common JavaScript Manual/Data types - Strings

Strings
Let's make a variable with a string as value; we will use string literal. Strings can be enclosed in double and single quotes (though in most languages strings are enclosed in double quotes and chars in single quotes).

Concatenation
We can concatenate strings using '+' operator. Let's add to string in variable 'a' string "world".

Length of string
Any string has a 'length' property that contains the number of chars in the string.

Split
String.split([separator]) - returns array of substrings that was obtained by separating String by separator. If separator is not defined then separator = ","

Getting substrings and char
We can get a substring from a string using the substr(index,len) and substring(indexA,indexB) methods. First returns the substring from 'index' with length equal to len. Second returns the substring from indexA to indexB. We can also get a char at some position using charAt function.

Position of substring
We can also get a position of some substring in a string using the indexOf and lastIndexOf methods. Both functions have two arguments but only the first is required: the string to be searched and the position from that the string is searched. indexOf returns the first position of the substring and lastIndexOf returns the last position of the substring. If the substring is not found both functions return -1.