当前位置:网站首页>Differences between string() and tostring() methods

Differences between string() and tostring() methods

2022-06-13 04:49:00 Dandan's servant

String() and toString() It is the most commonly used conversion in our daily life js How to get , I don't try to distinguish the difference when I use it at ordinary times , Today I met the record .

Different 1( Yes undefined and null To deal with )

Use String Method pair undefined and null Handle , The result will be in string form undefined and null, But use toString The method will directly report an error .

Different 2( Binary processing of numeric strings )

toString Method can fill in a parameter , This parameter is a hexadecimal number , for example :

(10).toString(2)  ==>  '1010'
(10).toString(8)  ==>  '12'
原网站

版权声明
本文为[Dandan's servant]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130445503226.html