Skip to content

Instantly share code, notes, and snippets.

@alecat88
Created March 1, 2022 23:57
Show Gist options
  • Save alecat88/c6f3328cbedba09cd26f5298e8eec6ba to your computer and use it in GitHub Desktop.
Save alecat88/c6f3328cbedba09cd26f5298e8eec6ba to your computer and use it in GitHub Desktop.
Medium
// 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