artwl
artwl

Reputation: 3582

Why "\001" === "\u0001" is true in javascript?

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?

Upvotes: 1

Views: 5257

Answers (1)

SLaks
SLaks

Reputation: 887807

All of those strings are a single character; namely, Unicode code point 1.

Those are different ways of escaping it in the string literal.

Upvotes: 5

Related Questions