Table of Contents

    Strings in JavaScript: Manipulation and Examples

    Strings in JavaScript: Manipulation and Examples

    A string (or a text string) is a series of characters like "John Doe".

    Strings are written with quotes. You can use single or double quotes:

    
    var carName1 = "example string";   // Using double quotes
    var carName2 = 'example string';   // Using single quotes
    

    You can use quotes inside a string, as long as they don't match the quotes surrounding the string:

    
    var answer1 = "It's alright";     // Single quote inside double quotes
    var answer2 = "He is 'Don''";    // Single quotes inside double quotes
    var answer3 = 'I am "DON""';    // Double quotes inside single quotes
    

    You will learn more about strings later in this tutorial.