Menu Close

How to manipulate text strings in JavaScript

How to manipulate text strings in JavaScript

By the end of this article, you will have the ability to understand how text manipulation works. I will use the terms string and text interchangeably without getting scientific.

Here in this snapshot you can see the text length

  • length is property to get length of any string.
    Log

  • Find the first position of a character searching from left-to-right.
    Here we are finding the sting position by using

  • indexOf() method you next to pass the which character you want to get the positions.
    In this snap we are finding the “!” position.

  1. Here we can check of any string starting with any specific character.
  • It return True or False value
const text = "Hello!"
const result =  text.startsWith('H')

console.log("imsav log===>", result);
Enter fullscreen mode

Exit fullscreen mode

View Source
Posted in JavaScript