In addition to the built-in datatypes in native JS, jQuery also includes some extended data types (virtual types), such as Selectors, Events, etc.
1. String
String is the most common and is supported by almost any high-level programming language and scripting language. For example, "Hello world!" is a string. The type of string is string. For example
var typeOfStr = typeof "hello world";//typeOfStr is "string"
1.1 String 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"]
1.2 length attribute: returns the character length, for example, "hello".length returns 5
1.3 Convert string to Boolean:
An empty string ("") defaults to false, while a non-empty string defaults to true (such as "hello").
2. Number
Number type, such as 3.1415926 or 1, 2, 3...
typeof 3.1415926 returns "number"
2.1 Number converted to Boolean:
If a Number value is 0, it defaults to false, otherwise it is true.
2.2 Since Number is implemented using double-precision floating point numbers, the following situation is reasonable:
0.1 + 0.2 // 0.30000000000000004
3. Math
The following method is similar to the static method of Math class in Java.
Math.PI // 3.141592653589793
Math.cos(Math.PI) // -1
3.1 Convert strings to numbers: parseInt and parseFloat methods:
parseInt("123") = 123 (using decimal conversion)
parseInt("010") = 8 (using octal conversion)
parseInt("0xCAFE") = 51966 (using hexadecimal conversion)
parseInt("010", 10) = 10 (specify decimal conversion)
parseInt("11", 2) = 3 (specify binary conversion)
parseFloat("10.10") = 10.1
3.2 Number to string
When you append Number to the string, you will get the string.
"" + 1 + 2; // "12"
"" + (1 + 2); // "3"
"" + 0.0000001; // "1e-7"
Or use forced type conversion:
String(1) + String(2); //"12"
String(1 + 2); //"3"
4. NaN and Infinity
If the parseInt method is called on a non-numeric string, NaN (Not a Number) will be returned. NaN is often used to detect whether a variable is of numeric type, as follows:
isNaN(parseInt("hello", 10)) // true
Infinity represents an infinitely large or infinitely small value, such as 1 / 0 // Infinity.
Calling the typeof operator on both NaN and Infinity returns "numuber".
Also NaN==NaN returns false, but Infinity==Infinity returns true.
5. Integer and Float
It is divided into integer type and floating point type.
6. BOOLEAN
Boolean type, true or false.
7. OBJECT
Everything in JavaScript is an object. Performing a typeof operation on an object returns "object".
var x = {}; var y = { name: "Pete", age: 15 };
For the above y object, you can use dots to obtain attribute values. For example, y.name returns "Pete" and y.age returns 15
7.1 Array Notation (array access method to access objects)
var operations = { increase: "++", decrease: "--" } var operation = "increase"; operations[operation] // "++"; operations["multiply"] = "*"; // "*"
The above operations["multiply"]="*"; adds a key-value pair to the operations object.
7.2 Object loop access: for-in
var obj = { name: "Pete", age: 15}; for(key in obj) { alert("key is "+[key]+", value is "+obj[key]); }
7.3 Any object, regardless of whether it has attributes or values, defaults to true
7.4 Prototype attribute of object
Use fn (alias of Prototype) in jQuery to dynamically add objects (functions) to jQuery Instances
var form = $("#myform"); form.clearForm; // undefined form.fn.clearForm = function() { return this.find(":input").each(function() { this.value = ""; }).end(); }; form.clearForm() // works for all instances of jQuery objects, because the new method was added
8. OPTIONS
Almost all jQuery plug-ins provide an API based on OPTIONS. OPTIONS is a JS object, which means that the object and its properties are optional. Allow customization.
For example, using Ajax to submit a form,
$("#myform").ajaxForm();//By default, the Action attribute value of the Form is used as the Ajax-URL, and the Method value is used as the submission type (GET/POST)
$("#myform").ajaxForm({ url: "mypage.php", type: "POST" }); // Covers the submitted URL and submission type
9. ARRAY
var arr = [1, 2, 3];
ARRAY is a variable list. ARRAY is also an object.
Read or set the value of an element in ARRAY, using this method:
var val = arr[0];//val为1 arr[2] = 4;//现在arr第三个元素为4
9.1 Array loop (traversal)
for (var i = 0; i < a.length; i++) { // Do something with a[i] } 但是当考虑性能时,则最好只读一次length属性,如下: for (var i = 0, j = a.length; i < j; i++) { // Do something with a[i] } jQuery提供了each方法遍历数组: var x = [1, 2, 3]; $.each(x, function(index, value) { console.log("index", index, "value", value); });
9.2 Calling the push method on an array means adding an element to the end of the array, such as x.push(5); and x.[x.length] = 5; are equivalent
9.3 Other built-in methods of arrays:
var x = [0, 3, 1, 2]; x.reverse() // [2, 1, 3, 0] x.join(" – ") // "2 - 1 - 3 - 0" x.pop() // [2, 1, 3] x.unshift(-1) // [-1, 2, 1, 3] x.shift() // [2, 1, 3] x.sort() // [1, 2, 3] x.splice(1, 2) // 用于插入、删除或替换数组元素,这里为删除从index=1开始的2个元素
9.4 数组为对象,所以始终为true
10. MAP
The map type is used by the AJAX function to hold the data of a request. This type could be a string, an array<form elements>, a jQuery object with form elements or an object with key/value pairs. In the last case, it is possible to assign multiple values to one key by assigning an array. As below: {'key[]':['valuea','valueb']}
11. FUNCTION:匿名和有名两种
11.1 Context、Call和Apply
In JavaScript, the variable "this" always refers to the current context. $(document).ready(function() { // this refers to window.document}); $("a").click(function() { // this refers to an anchor DOM element });
12. SELECTOR
There are lot of plugins that leverage jQuery's selectors in other ways. The validation plugin accepts a selector to specify a dependency, whether an input is required or not:
emailrules: { required: "#email:filled" }
This would make a checkbox with name "emailrules" required only if the user entered an email address in the email field, selected via its id, filtered via a custom selector ":filled" that the validation plugin provides.
13. EVENT
DOM标准事件包括:blur, focus, load, resize, scroll, unload, beforeunload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, andkeyup
14. JQUERY
JQUERY对象包含DOM元素的集合。比如$('p')即返回所有
...
JQUERY对象行为类似数组,也有length属性,也可以通过index访问DOM元素集合中的某个。但是不是数组,不具备数组的某些方法,比如join()。
许多jQuery方法返回jQuery对象本身,所以可以采用链式调用:
$("p").css("color", "red").find(".special").css("color", "green");
但是如果你调用的方法会破坏jQuery对象,比如find()和filter(),则返回的不是原对象。要返回到原对象只需要再调用end()方法即可。

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!