代碼如下: var is = function(obj,type){ var toString=Object.prototype.toString,undefined; return obj===null&&type==='Null'|| obj===undefined&&type==='Undefined'|| toString.call(obj).slice(8,-1)===type; } //原文中有小括號包裹每個邏輯與運算,但根據運算符優先級,括號可以省略 //第一行聲明undefined,個人理解是為了提高性能,不必再去頂級作用域中查詢undefined.