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");
"abcbabcba".replace(/b/g,"_") // == "a_c_a_c_a"
– imma Jun 25 '14 at 15:40