Strings in JavaScript: Manipulation and Examples

Rumman Ansari   Software Engineer   2024-07-09 09:49:14   5656  Share
Subject Syllabus DetailsSubject Details
☰ TContent
☰Fullscreen

Table of Content:

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.

 



Stay Ahead of the Curve! Check out these trending topics and sharpen your skills.