`string.replace` weird behavior when using dollar sign ($) as replacement

pillows

New Member
I found a bug in my JavaScript code that I have isolated to a string replace that is acting in a way I didn't expect. Here is an example of the code:\[code\]var text="as";text = text.replace(text,"$\'");console.log(text);\[/code\]This prints an empty string to the console. I was expecting it to print $' to the console. Can anyone explain this?
 
Top