The conversion function converts:
//字符串转整数
let num1 = parseInt(str)
//字符串转小数
let num2 = parseFloat(str)
//保留小数点后两位
let num3 = parseFloat(str).toFixed(2)
//整数转字符串
let str = num1.toString()
//整数转字符串(16进制)
let str = num1.toString(16)
Mandatory type conversion:
//转换为布尔值
let bValue = Boolean(value)
//转换为整数
let num = Number(value)
//转换为字符串
let str = String(value)
Take advantage of weak type conversion
//数字转换为字符串
let str = ''+num
//字符串转换为数字
let num = str*1
let num = str-0
String to Object Conversion
//对象转为字符串
let str = JSON.stringify(obj)
//字符串转为对象
let obj = JSON.parse(str)