typeof的取值范围以及 typeof 和 instanceof 的区别

typeof: typeof 运算符把类型信息当作字符串返回。 typeof 返回值有六种可能: “number,” “string,” “boolean,” “object,” “function,” 和 "undefined. "我们可以使用typeof来获取一个变量是否存在,如if(typeof a!=“undefined”){}, 而不要去使用if(a)因为如果a不存在(未声明)则会出错,
相关文章
相关标签/搜索