let a = "null"
let b = "false"
let c = "1"
let d = {x: 1, y: {z: 2}}
if(JSON.parse(a)) {
// coding...
}
JSON.parse(a) // null null类型
JSON.parse(b) // false 布尔类型
JSON.parse(c) // 1 number类型
JSON.stringify(d) // '{"x":1, "y": {"z": 2}}'
类型转换,后端传了个字符串“null”和“false”
最新推荐文章于 2023-08-31 11:30:26 发布