Created
March 1, 2022 23:57
-
-
Save alecat88/c6f3328cbedba09cd26f5298e8eec6ba to your computer and use it in GitHub Desktop.
Medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Declare a variable and store some value. | |
const orgStr = 'JavaScript, often abbreviated as JS, is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled and multi-paradigm.'; | |
// To replace single instance, use replace(). | |
let newStr = orgStr.replace('JavaScript', 'TypeScript'); | |
console.log(newStr); | |
// To replace all instances, use replaceAll(). | |
let newStr2 = orgStr.replaceAll('JavaScript', 'TypeScript'); | |
console.log(newStr2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment