➢JavaScript strings are for storing and manipulating text.
EXAMPLE:
let Name1 = "Sanvi"; // Using double quotes let Name2 = 'Sanvi'; // Using single quotes
EXAMPLE:
let x = "It's alright"; // Single quote inside double quotes let y = "He is called 'joshik'"; // Single quotes inside double quotes let y = 'He is called "joshik"'; // Double quotes inside single quotes
String Length
➢To find the length of a string, use the built-in length property:
EXAMPLE:
let Name = "Manu"; let length = Name.length
Escape Character
➢Because strings must be written within quotes, JavaScript will misunderstand this string:
EXAMPLE:
let Name = "We welcome you"to"BMR EDUCATIOn";
➢The string will be chopped to "We are the so-called ".
➢The solution to avoid this problem, is to use the backslash escape character.
➢The backslash (\) escape character turns special characters into string characters: