GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Home
  • ES6
  • Web
  • JS BOM
  • JS DOM
  • Web API
  • React
  • Node.js
  • Express
  • React Native
  • JavaScript Array Methods
  • Regular Expressions
  • ES Next
  • Playground

This view

  • Original page
  • New address

GeezerVison is showing www.javascripttutorial.net — JavaScript String Methods

Home » JavaScript String Methods

This page provides the most commonly used JavaScript string methods that help you manipulate strings effectively.

Section 1. Searching #

Mastering the string search methods can help you analyze text more efficiently. These sections introduce the string search methods that allow you to locate and verify substrings within strings.

  • search() – locate a substring in a string using a regular expression.
  • indexOf() – get the index of the first occurrence of a substring in a string.
  • lastIndexOf() – find the index of the last occurrence of a substring in a string.
  • includes() – check if a string contains a substring.
  • startsWith() – check if a string starts with another string.
  • endsWith() – determine if a string ends with another string.

Section 2. Trimming #

This section introduces the string trimming methods that allow you to remove unwanted whitespace characters from a string, ensuring your text is clean and well-formatted.

  • trim() – remove whitespace characters from a string.
  • trimStart() – remove the leading whitespace characters of a string.
  • trimEnd() – remove the ending whitespace characters of a string.

Section 3. Padding #

Padding strings is a useful technique for formatting text. This section introduces two string methods padStart() and padEnd() for padding strings.

  • padStart() – pad the beginning of a string with another string until the resulting string reaches a specified length.
  • padEnd() – pad the end of a string with another string until the resulting string reaches a certain length.

Section 4. Extracting #

This section introduces the extracting string methods that allow you to break down strings into smaller pieces and extract specific substrings:

  • split() – split a string into an array of substrings.
  • substring() – extract a substring from a string.
  • slice() – extract a part of a string.

Section 5. Concatenating & interpolating #

Learn how to concatenate strings and substitute variables directly within strings using template literals.

  • concat() – concatenate multiple strings into a new string.
  • Template literals – learn how to use template literal to substitute variables directly within a string in a more flexible and readable way.

Section 6. Replacing #

This section introduces replacing string methods that allow you to perform data cleaning and transformation effectively.

  • replace() – replace a substring in a string with a new one.
  • replaceAll() – replace all occurrences of a substring that matches a pattern with a new one.

Section 7. Changing cases #

This section introduces various case-changing methods that allow you to convert characters in strings to lowercase or uppercase.

  • toUpperCase – return a string with all characters converted to uppercase.
  • toLowerCase – return a string with all characters converted to lowercase.

Was this helpful?

Thank you for your feedback!

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.