In the dynamic landscape of JavaScript, strings are fundamental data types that encapsulate textual data. To manipulate and extract data from strings, JavaScript offers a plethora of built-in string functions. Let's delve into some of these functions and explore their practical applications with examples.

Strings in JavaScript are immutable, meaning once a string is created, it cannot be altered. However, with various string functions, you can work with them to generate new strings based on the original data.

Basic String Manipulation
The following JavaScript string functions provide foundational methods for manipulating strings.

To find the length of a string, you can use the length property. For instance, "Hello, World!".length returns 13.
Extraction and Search

Extracting and searching within strings are common operations. The JavaScript string function indexOf() returns the first index at which a given element can be found in a string. For example, "Hello, World!".indexOf("o") returns 4.
The function lastIndexOf() returns the last index at which a given element can be found. "Hello, World!".lastIndexOf("o") returns 7. If the element is not found, these functions return -1.
Slicing and Splicing

The slice() method extracts a section of a string and returns it as a new string. "Hello, World!".slice(0, 5) returns "Hello". The original string remains unchanged.
The substring() function also extracts a section of a string but allows for negative indexing. "Hello, World!".substring(-5) returns "World!".
Converting Strings

Converting a string to uppercase or lowercase is a common requirement in several use cases. JavaScript provides toUpperCase() and toLowerCase() functions for achieving this.
"Hello, World!".toUpperCase() returns "HELLO, WORLD!", while "HELLO, WORLD!".toLowerCase() returns "hello, world!".




















Capitalization and Trimming
The charAt() function returns the character at a specified index in a string. "Hello, World!".charAt(0) returns "H".
Use trim() for removing any whitespace from the beginning and end of a string. " Hello, World! ".trim() returns "Hello, World!".
Mastery of these string functions will empower you to swiftly and efficiently work with data within strings in your JavaScript applications.