JSLite - test operations


If you have any questions, you are welcome to communicate in these places, and you are welcome to join the JSLite.io organization team for joint development!

$.isDocument

Determine whether the object is [document].

$.isDocument(document) //⇒ true

$.isWindow

Determine whether the parameter is a window (window object), and return true if so. This is useful when dealing with iframes, because each iframe has its own window object, and checking these objects using the normal method obj==window will fail.

$.isFunction

Determine whether the object is a function [function].

$.isFunction(function(){}) //⇒ true

$.isObject

Determine whether it is Object.

$.isObject({})  //⇒ true

$.isPlainObject

$.isPlainObject(object) ⇒ boolean
If passed "{}" or "new Object" Returns true if created. Determine whether the object is a pure object.

$.isPlainObject({})         // => true
$.isPlainObject(new Object) // => true
$.isPlainObject(new Date)   // => false
$.isPlainObject(window)     // => false

$.isArray

Determine whether it is an [array].

$.isArray([1,2,3])  //⇒ true

$.isJson

Determine whether it is an [array].

$.isJson({})  //⇒ true

$.contains

$.contains(parent, node) ⇒ booleanparentwhether it contains nodeNode object.

$.contains($("#box")[0],$(".boxss")[0]) //⇒ parent是否包含node节点对象

$.likeArray

Determine whether the object is an array or a character.

$.likeArray([1,2,3])     //⇒ true
$.likeArray("222")  //⇒ true

$.type

Get the type of JavaScript object. Possible types are: null undefined boolean number string function array date regexp object error .

$.type(true)  //⇒ Boolean
$.type("div") //⇒ String

$.matches

If the current node can be found by the specified css selector, return true, otherwise return false.
$.matches(element,selector) ⇒ boolean

$.matches($("#box")[0], "#box")//⇒ true

is

Determine whether the element in the currently matched element set is For a selector, DOM element is(selector) ⇒ boolean
is(element) ⇒ boolean

$("#box").is("div");  //⇒ true  
$("#box").is("#box");  //⇒ true  
$("#box").is("#boxsss");  //⇒ false  
$("div").is($("#box")[0]) //⇒ true  节点是否在 $("#box")[0] 是否再集合中