Here’s yet another example of the JavaScript flexibility. You can simply call .replace() on every string and pass a regex as a parameter!
var str = 'my simple string'; str.replace(/ /g, '-'); // now 'str' will contain 'my-simple-string' |
Here’s yet another example of the JavaScript flexibility. You can simply call .replace() on every string and pass a regex as a parameter!
var str = 'my simple string'; str.replace(/ /g, '-'); // now 'str' will contain 'my-simple-string' |