I need a javascript alternative to the StringEscapeUtils in java, specifically for converting input strings like:
He didn't say, "Stop!"
The desired output format should be:
He didn't say, \"Stop!\"
Is there a similar function available in underscore or any other utility library?
Although underscore's escape API converts as follows:
var a = '"test"'; _.escape(a)
resulting in:
""test""
I actually require the format: \"test\"'