Piyush Deshmukh
Piyush Deshmukh

@Piyushd_21

13 Tweets 5 reads May 29, 2022
⚑️ JavaScript String Methods Explained ⚑️
- String replace() Method
A Visual Thread πŸ§΅πŸ‘‡
🌻 Note 🌻
β†’ This Thread is part of "JavaScript String Methods" series.
β†’ In this series we will cover all the JavaScript String Methods in the form of Visual Thread.
β†’ There will be 27 String Methods which will be explained.
Contents of this Thread -
1. What does replace() method do ?
2. Syntax
3. Replace First Occurrence
4. Replace all the Occurrences
5. Replace without considering Uppercase/Lowercase
6. Pass a Function as a replacement
Let's Begin ↓↓↓
πŸ“ŒNOTE -
- In this thread I will often use the term Regex, so kindly refer the below article to learn about it πŸ‘‡
- In short ~
Regex are patterns used to match character combinations in strings.
developer.mozilla.org
➜ What does replace() method do ?
- The replace() method returns a new string with the specified string/regex replaced.
➜ Syntax
➜ Replace First Occurrence of the given parameter
- To replace the First Occurrence we can use both String and Regex as parameters.
➜ Replace all the Occurrences
- To replace all the Occurrences of the given parameter we use Regex with g switch.
➜ Replace without considering Uppercase/Lowercase
- To replace the Occurrences of the given parameter we use Regex with i switch.
➜ Pass a Function as a replacement
- To explain this I have used a Function which generates Random digits between 0 and 9.
πŸ‘‰ Want High Quality Notes ?
- Click here πŸ‘‡
github.com
πŸ‘‰ Want the Whole Series at one place ?
- Click here πŸ‘‡
That's all for now!!
Follow @Piyushd_21 for more
Hope you liked the content!
Thanks!!
Have a nice day!!πŸ˜€

Loading suggestions...