The difference between jquery length() and size(): 1. length is an attribute, and size is a method; 2. The values obtained by length and size are the same, but if you want to get the length of a string, you have to use length.
The operating environment of this tutorial: windows7 system, jquery3.2.1 version. This method is suitable for all brands of computers.
The difference between jquery length() and size():
1. The difference in identity, basic_string<>
has dual identities. One is to replace the traditional C string, so the corresponding function length should be given for strlen in C. Another identity can be used as an STL container, so size()
is given as per the convention for STL containers.
2. The difference in type is that length is an attribute and size() is a method.
3. The difference in usage is that if you just want to get the number of elements, the effect is the same. The values obtained by length and size() are the same; but if you want to get the length of the string, you have to Use length.
4. The difference in encoding. The actual situation is that the length() method returns the number of character code units encoded in UTF-16, which is not necessarily the actual number of characters we think. Similarly, the codePointCount()
method returns the number of code points, which is the actual number of characters.
Because commonly used uniCode characters can be represented using one code unit, but some auxiliary characters require a pair of code units to be represented. The length() method calculates the number of code units, and the codePointCount()
method calculates the number of code points.
5. Regarding the difference between objects, the length()
method in java is for the string String. If you want to see the length of the string, use the length() method. The size() method in .java is for generic collections. If you want to see how many elements this generic has, call this method to view it.
Related free learning recommendations: javascript (video)
The above is the detailed content of The difference between jquery length and size(). For more information, please follow other related articles on the PHP Chinese website!