//清单 6. JavaScript instanceof 运算符代码 function instance_of(L, R) {//L 表示左表达式,R 表示右表达式 var O = R.prototype;// 取 R 的显示原型 L = L.__proto__;// 取 L 的隐式原型 while (true) { if (L === null) return false; if (O === L)// 这里重点:当 O 严格等于 L 时,返回 true return true; L = L.__proto__; } } //在zeptojs中 zepto.Z = function(dom, selector) { dom = dom || [] dom.__proto__ = $.fn dom.selector = selector || '' return dom } zepto.Z.prototype = $.fn zepto.isZ = function(object) { return object instanceof zepto.Z } //判断变量是否存在 if(window.a) {} if(typeof(a) === 'undefined') {} a = []; a instanceof Array ; //true typeof(a) // object