简体   繁体   English

javascript如何将090(数字)转换为'090'(字符串)?

[英]javascript how to convert 090(Number) to '090'(String)?

how to convert 090(Number) to '090'(String)?如何将 090(Number) 转换为 '090'(String)?

everything I try to do with 090(Number), it will be converted into 90(Number) automatically, so I get 90(Number) or '90'(String).我尝试用 090(Number) 做的所有事情,它都会自动转换为 90(Number),所以我得到 90(Number) 或 '90'(String)。 I want the '090'.我想要'090'。 090 + ' ',get '90', but I want '090'; 090 + ' ',得到'90',但我想要'090'; plus, 9. + 9, I get '99', not '9.9'.另外,9. + 9,我得到'99',而不是'9.9'。 why为什么

090 is either 90, or a syntax error, depending whether you forgot strict mode or not. 090 要么是 90,要么是语法错误,这取决于您是否忘记了严格模式。 Meanwhile, 077 is either 63 or syntax error.同时,077 是 63 或语法错误。 Do "use strict";做“严格使用”; Also, as @sandes said in his very good (although downvoted and deleted) answer is perfectly correct: 90 is a number, "090" is one particular string representation of it.此外,正如@sandes 在他的非常好的(尽管被否决和删除)中所说的那样,答案是完全正确的:90 是一个数字,“090”是它的一个特定字符串表示。 You can convert a number to any kind of string representation you want, but the default one is 90 The computer can remember "090" as a string, but it remembers 90 as 01000010 10110100 00000000 00000000. There is no way to remember the number 090 as distinct.您可以将数字转换为您想要的任何类型的字符串表示形式,但默认为 90 计算机可以将“090”作为字符串来记住,但它会将 90 记住为 01000010 10110100 00000000 00000000。没有办法记住数字 090一样与众不同。

thanks @amadan谢谢@amadan

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM