如何将数字010转换为字符串“010”。

编程入门 行业动态 更新时间:2024-10-24 14:20:13
本文介绍了如何将数字010转换为字符串“010”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在控制台中执行一些随机表达式时,我发现

While executing some random expressions in console, I just found that

010 +返回 8 (甚至011,0100 ..通过考虑八进制数系统返回结果)

010 + "" returning 8 (even 011,0100.. are returning results by considering octal number system)

如果需要,我该怎么办?我想将数字 010 转换为字符串010?不仅是 010 ,而是针对每个相似的数字。我设法为这个这里找到了类似的解释。但这并没有解释如何将其转换为精确的字符串版本。

What would I have to do if I want to convert a number 010 to a string "010"? Not only for 010 but for every similar numbers. I managed to find a kind of similar explanation for this here. But that is not explaining how to convert it into a exact string version.

推荐答案

在Javascript 010 是八进制文字,并在十进制文字中转换为8。事实上,你应该避免它,因为严格模式不允许使用它。

In Javascript 010 is octal literal and converts to 8 in decimal literal. In fact, you should avoid it, as strict mode disallows to use it.

除了解析函数体字符串之外,没有办法区分八进制和十进制表示法:)

There is no way to distinguish between octal and decimal notation other than parsing function body string :)

更多推荐

如何将数字010转换为字符串“010”。

本文发布于:2023-11-10 15:50:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575797.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   字符串   如何将   数字

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!