the code is:
console.log("\1" === "\u0001");//true
console.log("\01" === "\x01");//true
console.log("\001" === "\u0001");//true
why "\001" === "\u0001"
is true,who can tell me why?
the code is:
console.log("\1" === "\u0001");//true
console.log("\01" === "\x01");//true
console.log("\001" === "\u0001");//true
why "\001" === "\u0001"
is true,who can tell me why?
-
2
Because they're all the same character? If you were expecting the form seen in the literal syntax to be pared, you'd need to escape the
\
character.console.log("\\1" === "\\u0001");// false
– I Hate Lazy Commented Oct 10, 2012 at 15:34 - They are all the same character. Those are different ways to escape it. – gen_Eric Commented Oct 10, 2012 at 15:35
1 Answer
Reset to default 5All of those strings are a single character; namely, Unicode code point 1.
Those are different ways of escaping it in the string literal.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745394150a4625800.html
评论列表(0条)