JavaScript String Methods
JavaScript Basics

JavaScript String Methods

JavaScript String Methods

Basic String Methods

JavaScript strings are primitive and immutable, meaning that all string methods produce a new string without altering the original.

JavaScript String Length

The length property retrieves the length of a string.


<!DOCTYPE html>

<h1>JavaScript Strings</h1>
<h2>The length Property</h2>

<p>The length of the string is:</p>
<p id="demo"></p>

document.getElementById("demo").innerHTML = text.length;


Extracting String Characters

Four methods are available for extracting string characters:

  1. The at(position) Method
  2. The charAt(position) Method
  3. The charCodeAt(position) Method
  4. Using property access [] similar to arrays.

JavaScript String charAt()

The charAt() method retrieves the character at a specified index (position) in a string.


Take a look into your desired course