Replacing {t} in the variable var2, removes a '$' symbol from var1 and renders it as abc$abc instead of abc$$abc in the final result.
var var1 = 'abc$$abc';
var var2 = 'You are comparing {t} entity';
$('#div1').append('<div id="div2">' + var2.replace('{t}','<a href="' + var1 + '" target="_self">' + '</a>') + '</div>');
The closest questions I could find was Javascript append element with special characters, but even that couldn't address the problem.
Undoubtedly, I can check if the resultant string contains just one $ of two $s but i want to know if there is anything wrong with append above, as well as, if there is any generic way to achieve the result with the resultant string being restored with two $ signs.