代码示例:(标识:eg_js_type_convert_number_1)
<!DOCTYPE html>
<html>
<body>

<p>把数字 1 转换为其他类型:</p>

<p>Converting the number 1 to other types:</p>

<p id="demo" style="font-family:courier"></p>

<script>
var x = 1;
document.getElementById("demo").innerHTML =
"Number : " + Number(x) + "<br>" +
"String : " + String(x) + "<br>" +
"Boolean: " + Boolean(x);
</script>

</body>
</html>
运行结果: