let codeString = "perl";
let stackString = "LAMP uses ${codeString}";
- string index, char position in string, starts at 0
let newString = `
This string spans
more than one line`; // Backticks
let anotherString = "A line that \
spans two lines"; // Backslash
let recommendedMethod = "Use the concatenatiion" +
'operator which has wider browser support";
let a = 'hello,';
let b = ' there';
a + b; 'hello, there'
const stringA = "Circle";
let stringLen = stringA.length; // 6
string0 = "This is a single quote: \'";
string1 = "This is a double quote: \"";
string2 = "This is a backslash: \\";
let result = targetString.substring(startIndex , endIndex);
let phoneNumberA = "1-800-555-5555"; // 14 chars
let phoneNumberB = "555-123-5555"; // 12 digits
let lenA = phoneNumberA.length;
let lastFourDigits = phoneNumberA.substring(lenA - 4, lenA);
let actionWord = actionWord.toUpperCase() + "!";
- Returns -1, or index of 1st match
let targetString = "0123456789";
let digitIndex = targetString.indexOf('5'); // 5
- Removes searched for subString, inserts new subString at index of old
let newString = originalString.replace("gray", "grey");
let newString = originalString.replace("colour", "color");
let noBookendWhiteSpaceString = messyString.trim();
- Returns empty string, or char located at index
let charAtIndex = targetString[10];
Return "\"" + charAtIndex + "\" is the tenth char.";
- Returns the difference of ASCII vals
let firstString = "IDK";
let secondString = "IDK";
Return secondString.localeCompare(firstString); // 0 or IDK
let stringObject = new String("Cello");