[英]Javascript String Type Conversion issue in Vs code
Can anyone tell me whats wrong with my code?谁能告诉我我的代码有什么问题? i have just started learning Javascript and currently on type conversions.我刚刚开始学习 Javascript,目前正在进行类型转换。
let main = true; console.log(typeof main); main = string(main); console.log(typeof main);
the first two lines of code correctly shows type of main as boolean but when in the thrid line i convert it to string, it doesn't show anything.前两行代码正确地将 main 类型显示为 boolean 但是在第三行中我将其转换为字符串时,它什么也不显示。
Using VS CODE Editor.使用 VS CODE 编辑器。
Correct class is, String
not string
正确的 class 是, String
不是string
Replace代替
main = string(main)
with和
main = String(main)
Use toString for cast:使用 toString 进行强制转换:
let main=true; alert(typeof main); main = main.toString(); alert(typeof main);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.