my name is george phillips and i am a freelance web developer based in london

blog

JavaScript Strings

Strings can be created by using double or single quotes.

var string = "a string";
var string2 = 'another string';

If your string contains quotes or double quotes, they need to be escaped with the backslash like so:

'Then she said, "Man I can/'t believe I had to escape the darn quote!"';

We can do operations on strings with operators.

The + operator concatenates strings.

var string1 = 'holy', string2 = ' cow!', string3 = string1 + string2; // string3 = 'holy cow!'

Leave a Reply