JavaScript provides a number of methods for manipulating strings. Here are some of the most commonly used methods:

  1. charAt(): This method returns the character at a specified index in a string.
  2. Example:

    rust
    const str = "Hello, world!"; const char = str.charAt(1); console.log(char); // Output: "e"
  3. concat(): This method concatenates two or more strings and returns a new string.
  4. Example:

    javascript
    const str1 = "Hello"; const str2 = "world"; const str3 = str1.concat(", ", str2, "!"); console.log(str3); // Output: "Hello, world!"
  5. indexOf(): This method returns the index of the first occurrence of a specified value in a string.
  6. Example:

    rust
    const str = "Hello, world!"; const index = str.indexOf("world"); console.log(index); // Output: 7
  7. slice(): This method extracts a section of a string and returns a new string.
  8. Example:

    rust
    const str = "Hello, world!"; const newStr = str.slice(7, 12); console.log(newStr); // Output: "world"
  9. toUpperCase(): This method converts all characters in a string to uppercase.
  10. Example:

    rust
    const str = "Hello, world!"; const upperCaseStr = str.toUpperCase(); console.log(upperCaseStr); // Output: "HELLO, WORLD!"
  11. toLowerCase(): This method converts all characters in a string to lowercase.
  12. Example:

    rust
    const str = "Hello, world!"; const lowerCaseStr = str.toLowerCase(); console.log(lowerCaseStr); // Output: "hello, world!"

    These are just a few examples of the many string methods available in JavaScript. You can learn more about these methods and others in the JavaScript documentation.