Skip to content

Instantly share code, notes, and snippets.

@Yunkou
Created April 16, 2016 09:56
Show Gist options
  • Save Yunkou/7ed6102e6025267ab7460d006d86890c to your computer and use it in GitHub Desktop.
Save Yunkou/7ed6102e6025267ab7460d006d86890c to your computer and use it in GitHub Desktop.
判断js值是否是xx类型
/* 检测对象类型
* @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