常用javascript类型判断

//判断是不是数组
console.log(Object.prototype.toString.apply([])==='[object Array]')
//判断是不是函数
console.log(Object.prototype.toString.apply(function(){})==='[object Function]')
//判断是不是null
console.log(Object.prototype.toString.apply(null)==='[object Null]')
//判断是不是undefined
console.log(Object.prototype.toString.apply(undefined)==='[object Undefined]');
//判断是不是字符串
console.log(Object.prototype.toString.apply('str')==='[object String]')

posted @ 2015-03-20 14:18  ollie_sk8  阅读(160)  评论(0编辑  收藏  举报