判断js中的类型:
alert(Object.prototype.toString.apply([1,2])); //"[object Array]" alert(Object.prototype.toString.apply('str')); //"[object String]" alert(Object.prototype.toString.apply(1)); //"[object Number]" alert(Object.prototype.toString.apply(null)); //"[object Null]" alert(Object.prototype.toString.apply()); //"[object Undefined]" alert(Object.prototype.toString.apply(function(){})); //"[object Function]" alert(Object.prototype.toString.apply(true)) //"[object Boolean]" alert(Object.prototype.toString.apply(new Object())); //"[object Object]"
function aa(){
console.log("aa测试用例");
}
var b={};
//aa.call(b); //相当于b.aa(),将aa()方法赋给b调用。
aa.apply(b); //相当于b.aa(),将aa()方法赋给b调用。
patientsDirection = [{ name: '入病房', clickstatus: false }, { name: '走廊', clickstatus: false },
{ name: '补液室', clickstatus: false }, { name: '手术室', clickstatus: false },
{ name: 'DSA室', clickstatus: false }, { name: '入ICU', clickstatus: false },
{ name: '自动离院', clickstatus: false }, { name: '好转离院', clickstatus: false },
{ name: '死亡', clickstatus: false }, { name: '转院', clickstatus: false },
{ name: '诊室', clickstatus: false }, { name: '留观', clickstatus: false }];
console.log(typeof patientsDirection,patientsDirection instanceof Array,Object.prototype.toString.call(patientsDirection)==="[object Array]");
console.log(typeof(Object.prototype.toString.apply([1,2])));