Explain Strings in Javascript?

Strings are useful for holding data that can be represented in text form. Some of the most-used operations on strings are to check their length, build and concatenate them using the + and += string operators, check for the existence or location of substrings with the indexOf() method, or extract substrings with the substring() method.

JavaScript String Length

The length property returns the length of a string:

There are 3 methods for extracting a part of a string:

slice(start, end)
substring(start, end)
substr(start, length)

JavaScript String slice()

slice() extracts a part of a string and returns the extracted part in a new string.

The method takes 2 parameters: the start position, and the end position (end not included).

JavaScript String substring()

substring() is similar to slice().

The difference is that substring() cannot accept negative indexes.

JavaScript String substr()

substr() is similar to slice().

The difference is that the second parameter specifies the length of the extracted part.