This explanation note is for their own in the process of looking at the source of some problems encountered in the answer, may not have reference to the public, but you can see if there is no place you do not understand, mutual learning, mutual progress.

1. Function init

 

<div id="one"></div> STR =" hello, <b>my name is</b> ", HTML = $.parsehtml (STR); console.log(html); var context={class:"classname"}; var t=jQuery.parseHTML( "34534,<p>", context && context.nodeType ? context.ownerDocument || context : document, true ) ; console.log(context && context.nodeType ? context.ownerDocument || context : document); console.log(t); console.log($("#one").nodeType); console.log(jQuery.merge("23",t));Copy the code

 

PushStack ()

<div id="one"></div>
<div></div>

console.log($("div").pushStack($("div")));
console.log($("#one").pushStack($("div")));
Copy the code

3. Eq function

 

<div id="one"></div>
    <div></div>
    <script>
        console.log($("div"));
        console.log($("#one"));
        console.log($("div").eq(0));
        console.log($("#one").pushStack($("div")));
    </script>
Copy the code

 

4, isPlainObject function

 

var obj=function(){}; var obj1=function(name){ this.name=name; } var obj2={}; var obj3={name:1} var nobj=new obj(); var nobj2=new obj1(); var obj4=new Object; console.log($.isPlainObject(nobj)); //false console.log($.isPlainObject(nobj2)); //false console.log($.isPlainObject(obj2)); //true console.log($.isPlainObject(obj3)); //true console.log($.isPlainObject(obj3)); //trueCopy the code

 

You can see that only objects created with {} and new Object can be treated as isplainObjects.

5, expando

Math.random() produces a decimal with 14 decimal places behind the decimal point. Plus the version number, plus the 0 before the decimal point, it’s 18 digits. \D matches any non-numeric character.

 

6, attr, prop

The differences are summarized as follows:

Attribute names may differ, although most attribute names are similar or consistent

While HTML attribute values always return strings, DOM attribute values can be integers, strings, objects, and more

The DOM attribute always returns the current state (value), while the HTML attribute (in most cases) returns the initialization state (value)

DOM attributes can only return values of fixed attribute names, whereas HTML attributes can return values of custom attribute names in HTML code

DOM attribute names and attribute values vary less between browsers than HTML attributes do, and DOM attributes have standards to follow

The recommendations for using.attr() and.prop() are as follows

.prop() is preferred because.prop() always returns the latest state (value)

Use.attr() only when it comes to custom HTML attributes, or forget about.attr()

 

7, jQuery. IsXMLDoc ()

This function is used to determine whether a DOM node is in an XML document or is itself an XML document.

This function is mainly used to determine whether the specified document is an XML document or an HTML(or XHTML) document.

This function belongs to the global jQuery object.