Get the App
SLTechnology News&Howtos  ›  Development  › 

Analyze the problem that the strict mode of JavaScript does not support octal

Shulou Source: shulou.com Published: 2022-06-02 17:56:08 09月23日 Update

This article mainly introduces "analyzing the problem that JavaScript strict mode does not support octal". In daily operation, I believe many people have doubts in analyzing the problem that JavaScript strict mode does not support octal. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to solve the problem of "analyzing JavaScript strict mode does not support octal". Next, please follow the editor to study!

With regard to the problem that the strict mode of JavaScript does not support octal, first of all, we all know that JavaScript can represent octal by adding 0 before the number.

As follows:

Let I = 011 position console.log (I); / / 9

But in strict mode, something goes wrong with this approach:

"use strict"; let I = 011; / / error / / Uncaught SyntaxError: Octal literals are not allowed in strict mode.console.log (I)

It means that octal is not supported in strict mode.

If you have to use it, you can use the curve to save the nation:

Set the octal data to a string, then convert it through parseInt, and set the conversion to octal.

"use strict"; let I = '011 destroy console.log (parseInt (I, 8)); / / 9 at this point, the study on "analyzing the problem that the strict mode of JavaScript does not support octal" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Octal patterns problems support analysis learning ways more help practical next you can pass characters strings that is meaning numbers data articles methods Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Apple macOS MariaDB Redmi