JS学习笔记——function方法(对象)的鉴别
摘要:基本方法: function temp(){}; typeof temp == "function" 存在问题: 1、在FireFox中,Html元素对象,也会返回function; 2、在IE中,在Iframe使用中也会出问题; 3、在Safari中,DOM中的NodeList类型也会被识别为function; 兼容方法: function isFunction(fn) { return Object.prototype.toString.call(fn) === "[object Function]"; } 为避免某些对象可能有自己的toStirng
阅读全文