Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String 和 toString 的区别 (2022-6-8) #34

Open
yaogengzhu opened this issue Jun 8, 2022 · 0 comments
Open

String 和 toString 的区别 (2022-6-8) #34

yaogengzhu opened this issue Jun 8, 2022 · 0 comments

Comments

@yaogengzhu
Copy link
Owner

String 和 toString 的区别

定义的位置不同

String 是 javascript的全局函数
toString() 是 Object 原型的一个方法

Sting()可以完成对 null 和 undefined 的转换

String() 可以将 null, undefined 转化为字符串;而 toString()不可以。

不同进制之间的转换

String()只支持转为普通字符串,不支持转为相应进制的字符串;

而Number.toString(radix)可以将一个Number对象转换对应进制的字符串;其中radix可选,表示数字几基数。

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant