Open links in new tab
  1. In JavaScript, a string is a sequence of characters used to represent text. Strings are immutable, meaning their content cannot be changed after creation. They can be created as primitives (preferred) or as objects using the String constructor.

    Creating Strings

    Strings can be created using:

    • String Literals: Enclosed in single ('), double ("), or backticks (`) for template literals.

    let str1 = 'Hello'; // Single quotes
    let str2 = "World"; // Double quotes
    let str3 = `Hello, ${str2}!`; // Template literal
    Copied!
    • String Constructor: Creates a string object (not recommended due to potential issues in comparisons).

    let strObj = new String('Hello');
    Copied!

    Accessing Characters

    Characters in a string can be accessed using:

    • Bracket Notation:

    let char = "JavaScript"[4]; // 'S'
    Copied!
    • charAt() Method:

    let char = "JavaScript".charAt(4); // 'S'
    Copied!

    Common String Methods

    JavaScript provides numerous methods to manipulate strings:

    • Finding Length:

    let length = "JavaScript".length; // 10
    Copied!
    • Concatenation:

    let result = "Hello" + " " + "World"; // "Hello World"
    Copied!
  1. JavaScript String Methods - W3Schools

    There are 4 methods for extracting string characters: 1. The at(position)Method 2. The charAt(position)Method 3. The charCodeAt(position)Method 4. Using property access …
    Javascript String charCodeAt

    The charCodeAt()method returns the code of the character at a specified index in a string: The method returns a UTF-16 code (an integer between 0 and 65535).

    Javascript String at

    ES2022 introduced the string method at(): The at()method returns the character at a specified index (position) in a string. The at()method is supported in all modern browsers since March 2022:

    Browser Support

    at()is an ES2022 feature. JavaScript 2022 (ES2022) is supported in all modern browsers since March 2023:

    Extracting String Parts

    There are 3 methods for extracting a part of a string: 1. slice(start, end) 2. substring(start, end) 3. substr(start, length)

  2. String - JavaScript - MDN

    Jul 10, 2025 · Some of the most-used operations on strings are to check their length, to build and concatenate them using the + and += string operators, checking for the existence or location of …

  3. The Beginner's Guide to JavaScript Strings By Examples

    In this tutorial, you will learn about the JavaScript strings and their basic operations such as accessing characters and comparing strings.

  4. JavaScript Strings - GeeksforGeeks

    Sep 25, 2025 · A JavaScript String is a sequence of characters, typically used to represent text. In JavaScript, there is no character type (Similar to Python and different from C, C++ and Java), so a …

  5. JavaScript Strings | W3Docs JavaScript Tutorial

    In JavaScript, the strings are used for storing and manipulating text. On this page, you will learn how to create strings, use them and make comparisons.

  6. JavaScript String (with Examples) - Programiz

    In JavaScript, string is a primitive data type that represents textual data. In this tutorial, you will learn about JavaScript strings with the help of examples.

  7. People also ask
    Loading
    Unable to load answer
  8. What Is a String in JavaScript, and What Is String Immutability?

    Strings are an important part of programming, and in future lessons, you will learn advanced techniques for manipulating them and harnessing their full potential to create dynamic and interactive applications.

  9. Creating and Manipulating Strings in JavaScript - Tutorial Republic

    In this tutorial you will learn how to create and manipulate strings in JavaScript. A string is a sequence of letters, numbers, special characters and arithmetic values or combination of all.

  10. JavaScript String Methods & Operations - Complete Guide

    Mar 22, 2026 · Learn JavaScript string manipulation with comprehensive examples. Covers string methods, operations, special characters, and common interview questions. Master string indexing, …

  11. JavaScript Strings: The Basic Methods and Functions | JavaScript.com

    Learn the basics of JavaScript Strings with code examples and small tutorials and descriptions on how each string function and method works.

    • Alison Free Learning
      https://alison.com › free-learning › diploma-courses
      About our ads

      Free Online Javascript Courses | Certified Free Courses

      SponsoredFree Online Javascript Courses From Beginner To Advanced - With Certificates. Thousands Of Free Certificate Courses. Study Online Anytime, Anywhere & At Your Own Pace.
    • Codecademy
      https://www.codecademy.com › get-started › free
      About our ads

      Online Javascript Courses | Beginner-Friendly Lessons

      SponsoredTake your skills to a new level and join millions of users that have learned Javascript. Learn key takeaway skills of Javascript and earn a certificate of completion.