var str1 = null; //str引用为空
var str2 = “”; //str引用一个空串
null没有分配空间,””分配了空间
var str1 = null;console.log(typeof str1) //object null是对象类型,表示空对象
var str2 = null;console.log(typeof str2) //string ” “是一个空格的 字符串
var str1 = null; //str引用为空
var str2 = “”; //str引用一个空串
null没有分配空间,””分配了空间
var str1 = null;console.log(typeof str1) //object null是对象类型,表示空对象
var str2 = null;console.log(typeof str2) //string ” “是一个空格的 字符串
文章来源:智云一二三科技
文章标题:js 中null和空字符的区别
文章地址:https://www.zhihuclub.com/198793.shtml