December 21, 2022
Estimated Post Reading Time ~

JOURNEY WITH JAVASCRIPT

JOURNEY WITH JAVASCRIPT

"Strings" in javascript Most frequently used string methods that are asked in interviews as well.



In JavaScript, a string is a sequence of characters enclosed in quotation marks. For example: let str = "This is a string."; Strings in JavaScript can be manipulated using a number of built-in methods.

1. chatAt( ) It returns the character at a specified index in the string



2. concat( ) The `concat( )` method concatenates (joins) two or more strings and returns a new string.



3. includes( ) The `includes( )` method determines whether a string contains a specified substring and returns a boolean value



4. indexOf( ) The `indexOf( )` method returns the index of the first occurrence of a specified substring in the string



5. replace( ) The `replace()` method replaces a specified substring with another substring and returns a new string



6. slice( ) The `slice( )` method extracts a section of a string and returns a new string.



7. split( ) The `split( )` method splits a string into an array of substrings and returns the new array.


8. endsWith( ) `endsWith( )` method is a string method that determines whether a string ends with the specified substring and returns a boolean value.



9. toUpperCase( ) and toLowerCase( ) The `toLowerCase( )` and `toUpperCase( )` methods convert a string to lowercase or uppercase, respectively.



10. repeat( ) The `repeat()` method returns a new string with the original string repeated the specified number of times. `repeat()` method is not supported in all browsers, so you may need to include a polyfill in your code to ensure compatibility with older browsers.



You can learn more about strings and their methods on the JavaScript documentation website. Resources


github.com
Learn-JavaScript/resources.md at main · deeqakkk/Learn-JavaScript
Contribute to deeqakkk/Learn-JavaScript development by creating an account on GitHub.

Source:


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.