Q:

How to convert "/" to "\" in javascript using replace method

The path is like "C:/TEST/", and I wanna convert it to "C:\TEST\", and I searched a lot and uneasy to made it.

A:

\ denotes the start of an escape sequence, so it has to be escaped with another \.
To replace globally, you need to use regex, which requires even more character escaping:
 > 'C:/TEST/'.replace(/\//g, '\\')
 "C:\TEST\"

