js判断类型 

Run Settings
LanguageJavaScript
Language Version
Run Command
/** * 判断类型 */ function typeOf(o){ var type = Object.prototype.toString.call(o); var name = type.substring(1,type.length-1).split(" ")[1].toLowerCase(); return { type:type, name:name, isNull:function(){ return this.name==="null"; }, isUndefined:function(){ return this.name==="undefined"; }, isNumber:function(){ return this.name==="number"; }, isBoolean:function(){ return this.name==="boolean"; }, isString:function(){ return this.name==="string"; }, isObject:function(){ return this.name==="object"; }, isArray:function(){ return this.name==="array"; }, isFunction:function(){ return this.name==="function"; } }; } var func = function fn(){} var types = [null,undefined,1,true,"Pheker",{name:"zhang"},[1],func]; types.map(function(v,i){ console.log(typeOf(v).name); }) console.log(typeOf(types[0]).isNull())
Editor Settings
Theme
Key bindings
Full width
Lines