Jquery Types Summary

Source: Internet
Author: User

JavaScript provides several built-in (built-in) datatypes. In addition to those, this page documents virtual types (virtual Class) like selectors, enhanced pseudo-types (pseudo class) like Events and all And everything wanted to know about Functions.

In addition to the built-in data types in native JS (built-in datatype), jquery also includes some extended data types (virtual types), such as selectors, events, and so on.

First, anything

The use of any virtual type in a jquery document indicates that any type can be used or should be expected.

Second, String

A string in JavaScript was an immutable (unchanging) object that contains none, one or many characters.

(1) var typeofstr = typeof "Hello World";//typeofstr is "string"

(2) Built-in method (built-in Methods):

"hello".charAt( 0 ) // "h" "hello".toUpperCase() // "HELLO" "Hello".toLowerCase() // "hello" "hello".replace( /e|o/g, "x" ) // "hxllx" "1,2,3".split( "," ) // [ "1", "2", "3" ]

(3) Length property: Returns the length of the character, such as "Hello". length returns 5

(4) A string is converted to Boolean: An empty string ("") defaults to False, and a non-empty string is true (such as "Hello").

Third, htmlstring

A string that is used to represent one or more DOM elements in a jquery document is specified as Htmlstring, which is typically created and inserted into the document. When passed as a parameter to the jquery () function, the string is started and parsed with <tag> until the last > character. Examples are as follows:

$( "<b>hello</b>" ).appendTo( "body" );  // <body><b>hello</b></body> $( "<b>hello</b>bye" ).appendTo( "body" );  // <body><b>hello</b></body> $( "bye<b>hello</b>" ).appendTo( "body" );  // 语法错误( Syntax error), unrecognized expression: bye<b>hello</b> $( $.parseHTML( "bye<b>hello</b>" ) ).appendTo( "body" );  // <body>bye<b>hello</b></body> $( "<b>hello</b>wait<b>bye</b>" ).appendTo( "body" );  // <b>hello</b>wait<b>bye</b>:

Iv. number

In native JavaScript, number is a 64-bit format IEEE 754 double precision (double-precision) value. Just as the string is immutable. All common operators are equivalent to the C language that can be applied to numbers (+,-, *,/,%, =, + =,-=, * =,/=, + +,--).

(1) The string is converted to boolean:if a number is zero and it defaults to false.

(2) Math, Math object:

Math. PI//3.141592653589793

Math. cos (MATH.PI)//-1

(3) parsing Numbers, converted to numbers: Parseint and Parsefloat methods

parseInt( "123" ) = 123 // (implicit decimal(十进制)) parseInt( "010" ) = 8 // (implicit octal(八进制)) parseInt( "0xCAFE" ) = 51966 // (implicit hexadecimal(十六进制)) parseInt( "010", 10 ) = 10 // (explicit decimal(十进制)) parseInt( "11", 2 ) = 3 // (explicit binary(二进制)) parseFloat( "10.10" ) = 10.1

(4) Numbers to Strings, number converted to string

[1] When the number is glued to the (append) string, the string is obtained.

"" + 1 + 2; "12" "" + (1 + 2); "3" "" + 0.0000001; "1e-7" parseint ( 0.0000001); //1 (!)

[2] or with coercion type conversion:

String (1) + string (2); "A" String (1 + 2); "3"

(5) Nan and Infinity (Both nan and Infinity are of type "number"):

If the parseint method is called on a non-numeric string, Nan (not a number) is returned, and isNaN is commonly used to detect whether a variable is a numeric type, as follows:

parseInt( "hello", 10 ) // NaN    isNaN( parseInt("hello", 10) ) // true

Infinity denotes infinity or infinity, such as 1/0//Infinity.

In addition Nan==nan returns false, but Infinity==infinity returns TRUE.

(6) Integer and float: is divided into the expression of integer and floating point type, are numeric types.

The Boolean: Boolean type, True or false.

Vi. Object Objects

Everything in JavaScript is object. The typeof operation on an object returns "Object".

var x = {}; var y = {name: "Pete", age:15};

For the Y object above, you can take a dot to get the property value, such as Y.name return "Pete", Y.age return 15

Jquery Types Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.