Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report