typeof 運算符

一:把類型信息看成字符串返回。typeof 返回值有六種可能: 「number,」 「string,」 「boolean,」 「object,」 「function,」 和 「undefined.」 二:咱們能夠使用typeof來獲取一個變量是否存在,如if(typeof a!=「undefined」){},而不要去使用if(a)由於若是a不存在(未聲明)則會出錯, 三:對於Array,Null等
相關文章
相關標籤/搜索