Created
February 14, 2013 08:14
-
-
Save Ovilia/4951288 to your computer and use it in GitHub Desktop.
JavaScript escape related string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In JavaScript string, you don't need to escape / | |
var a = "a/b"; // will give "a/b" | |
// But if you use \, it can be escaped | |
var b = "a\/b"; // will also give "a/b" | |
// While \ should always be escaped | |
var c = "a\b"; // will give "a" since \b means a backspace, | |
// which does nothing special here | |
// The right way for a \ | |
var d = "a\\b"; // will give "a\b" as expected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment