what does \ do on non escape characters?
c#, escaping, javascript, json
Solution
According to Mozilla:
For characters not listed [...] a preceding backslash is ignored, but this usage is deprecated and should be avoided.
https://developer.mozilla.org/en/JavaScript/Guide/Values%2c_Variables%2c_and_Literals#section_19
The `\/` sequence is not listed but there're at least two common usages:
<1> It's required to escape literal slashes in regular expressions that use the `/foo/` syntax:
var re = /^http:\/\//;
<2> It's required to avoid invalid HTML when you embed JavaScript code inside HTML:
<script type="text/javascript"><!--
alert('</p>')
//--></script>
... triggers: end tag for element "P" which is not open
<script type="text/javascript"><!--
alert('<\/p>')
//--></script>
... doesn't.
Problem
I asked another question poorly so i'll ask something else. According to http://www.c-point.com/javascript_tutorial/special_characters.htm there are a few escape characters such as \n and \b. However / is not one of them. What happens in this case? (`\/`) is the `\` ignored? I have a string in javascript `'http:\/\/www.site.com\/user'`. Not that this is a literal with `'` so with `"` it would look like `\\/` anyways i would like to escape this string thus the question on what happens on non 'special' escape characters. And another question is if i had `name:\t me` (or `"name:\\t me"` is there a function to escape it so there is a tab? i am using C# and these strings come from a JSON file