JS Strings

A string in JavaScript is a sequence of characters used to represent textual data. Strings are immutable, meaning their content cannot be changed once created.

Creating Strings

You can create a string in three ways:

Using Single Quotes ('):

Example
let str = 'Hello, World!';

Using Double Quotes ("):

Example
let str = "Hello, World!";

Using Template Literals (Backticks ` `):

  • Supports multi-line strings
  • Allows string interpolation (${expression})
Example
let name = 'John';
let greeting = `Hello, ${name}!`;
console.log(greeting); // Output: Hello, John!

Try it yourself


Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.