Fundamentals

Strings in JavaScript

What is a String?

A string represents textual data, written inside single quotes, double quotes, or backticks (template literals).

let single = 'Hello';
let double = "World";
let name = "John";
let template = `Hi, ${name}!`; // template literal

Common String Methods

  • length — returns the number of characters.
  • toUpperCase() / toLowerCase() — changes case.
  • slice(start, end) / substring() — extracts part of a string.
  • trim() — removes whitespace from both ends.
  • replace() — replaces part of a string with another.
  • split() — splits a string into an array based on a separator.

Ready to master real-world JavaScript development?

Learn JavaScript hands-on with mentor-led, live sessions.

Explore Course