// A crude way of determining if an object is a window
isWindow: function( obj ) {
return obj && typeof obj === "object" && "setInterval" in obj;
}
Here is how it works:
1. it detects if there is an object being returned
2. it detects if the object type is object
3. it sees if setInterval is a method of the object, setInterval is part of window.setInterval, it’s a method that’s only available in window object.
jQuery.isWindow
最新推荐文章于 2024-11-22 16:56:23 发布
本文介绍了一种简单的方法来判断一个对象是否为Window对象。通过检查对象是否存在、对象类型是否为对象以及该对象是否包含setInterval方法这三个步骤实现。setInterval是Window对象特有的方法。

1392

被折叠的 条评论
为什么被折叠?



