日期:2014-05-16  浏览次数:20340 次

js简单类型判断

function isArray(ob) {
var ret = false;

if(ob instanceof Array){
ret = true;
}
return ret;
}

function isObject(ob) {
return typeof ob == "object";
}

function isFunction(ob) {
return typeof ob == "function";
}

function isString(ob) {
return typeof ob == "string";
}

function isNumber(ob) {
return typeof ob == "number";
}

function isUndefined(ob) {
return typeof ob == "undefined";
}

function isMap(ob) {
var i = 0;

for(var x in ob)
i++;
return i > 0;
}