I came across a bit of code that looks something like this:
var str="I like blue";
str.replace(/blue/,"red");
What is happening here? When are string literals not required to be enclosed in quotes? What is the benefit of this approach as opposed to
str.replace("blue","red");
String.replacecan take a regex as the first argument./blue/is a regular expression literal./blue/is not a string literal, it's a regular expression literal..replacecan search for either a string or a regex.