String()
所有类型都可以转成字符串
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
//1.数值转字符串String()
var a = 100
var b = String(a)
console.log(a,typeof a,b,typeof b)
// 2.true或false或undefined转字符串
var c = true
var d = String(c)
console.log(typeof c,typeof d)
var e = undefined
var f = String(e)
console.log(typeof e,typeof f)
// 3.toString方法 null和undefind转不了
var g = 100
var h = g.toString()
console.log(g,typeof g,h,typeof h)
//4.用+号
var i = 100
var j = i+""
console.log(j,typeof j)
</script>
</head>
<body>
</body>
</html>