Just a string. Add ' to it every time there is a single quote.
replace works for the first quote, so you need a tiny regular expression:
replace
str = str.replace(/'/g, "\'");
2.1m questions
2.1m answers
60 comments
57.0k users