Why are Octal numeric literals not allowed in strict mode (and what is the workaround?)

前端 未结 4 519
攒了一身酷
攒了一身酷 2020-12-03 17:23

Why are Octal numeric literals not allowed in JavaScript strict mode? What is the harm?

4条回答
  •  情书的邮戳
    2020-12-03 18:06

    Nowadays, with large browser support to ES6, you could write this:

    const NINE = 0o11; // octal
    const TEN = 0b1010; // binary
    const SEVENTEEN = 0x11; // hexa
    

提交回复
热议问题