typeof的取值範圍以及 typeof 和 instanceof 的區別

typeof: typeof 運算符把類型信息當作字符串返回。 typeof 返回值有六種可能: 「number,」 「string,」 「boolean,」 「object,」 「function,」 和 "undefined. "我們可以使用typeof來獲取一個變量是否存在,如if(typeof a!=「undefined」){}, 而不要去使用if(a)因爲如果a不存在(未聲明)則會出錯,
相關文章
相關標籤/搜索