1
代码:为什么“ 001”===“ u0001”在JavaScript中为true?
console.log("\1" === "\u0001");//true
console.log("\01" === "\x01");//true
console.log("\001" === "\u0001");//true
为什么"\001" === "\u0001"
是真的,谁可以告诉我为什么吗?
代码:为什么“ 001”===“ u0001”在JavaScript中为true?
console.log("\1" === "\u0001");//true
console.log("\01" === "\x01");//true
console.log("\001" === "\u0001");//true
为什么"\001" === "\u0001"
是真的,谁可以告诉我为什么吗?
所有这些字符串都是单个字符;即Unicode code point 1。
这些是在string literal中转义它的不同方式。
因为他们都是一样的性格?如果您希望将字面语法中看到的表单进行比较,则需要转义'\'字符。 'console.log(“\\ 1”===“\\ u0001”); // false' –
它们都是[相同字符](http://codepoints.net/U+0001)。这些是[escape](http://mathiasbynens.be/notes/javascript-escapes)的不同方式。 –