Javascript - Leading zero to a number converting the number to some different number. not getting why this happening?

前端 未结 2 1479
無奈伤痛
無奈伤痛 2020-12-06 20:57

A leading zero to some number converting the number to some unknown number format. for example :

017 is getting converted to 15

2条回答
  •  独厮守ぢ
    2020-12-06 21:41

    One of the reasons to "use strict";

    (function() {"use strict"; 017})()
    
    // Firefox => SyntaxError: "0"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the \"0o\" prefix instead 
    // Chrome, Node => SyntaxError: Octal literals are not allowed in strict mode.
    

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_octal

提交回复
热议问题