Created
April 16, 2016 09:56
-
-
Save Yunkou/7ed6102e6025267ab7460d006d86890c to your computer and use it in GitHub Desktop.
判断js值是否是xx类型
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 检测对象类型 | |
* @param: obj {JavaScript Object} | |
* @param: type {String} 以大写开头的 JS 类型名 | |
* @return: {Boolean} | |
*/ | |
function is(obj, type) { | |
return Object.prototype.toString.call(obj).slice(8, -1) === type; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment