JS Strings

Creating strings

You can use single or double quotes.

    

let single = 'hello world';
let double = "hello world";


    

Mixing quotes

    

let single = 'This "string" is cool';
let double = "I should've known";


    

Escaping quotes

    

let single = 'I should\'ve known';
let double = "This \"string\" is cool";


    

Concatenating strings

    

let newString = "Hello " + "world";


    

Template literal

    

let a = `Hello world`;
let b = `I am ${1 + 1} years old`;


    

Length

    

'hello'.length;

let string = 'hello';
string.length;