1.What is a String in JavaScript?
In JavaScript, a string is a sequence of characters (letters, numbers, symbols, spaces) enclosed in quotes.
Strings are used to represent text such as names, messages, or any written data.
Ways to Create a String:
1.Single quotes (' '):
let str1 = 'Hello World';
2.Double quotes (" "):
let str2 = "JavaScript is fun!";
3.Backticks ( ) → Template Literals:
let name = "Dharshini";
let str3 = `Hello, ${name}!`; // allows variables & expressions inside
console.log(str3); // Hello, Dharshini!
    
Top comments (0)