According to the document using $’
will insert the part of the string that’s after the match. But I'm unable to get it to work.
let myStr = 'My little Alligator later';
console.log(myStr.replace('gator', '$’'));
I was expecting output to be "My little Alli later" (replacing "gator"
with " later"
, which is a string that comes after the match), but the actual output is "My little Alli$’ later"
. Why do I see '$’
in the output?