avoid to escape a special characters in javascript

后端 未结 5 1543
你的背包
你的背包 2020-12-01 20:01

My server returns value as support\\testing. When I get this value in client it can be escaped as support testing. \\t is escaped

5条回答
  •  旧时难觅i
    2020-12-01 20:51

    You can use tagged template literals

    var str = (s => s.raw)`support\testing`[0]
    

    The anonymous arrow function will serve as tag and s.raw contains the original input

提交回复
热议问题