1. What is JavaScript?
(1) HTML is just a markup language that describes the appearance of a web page. It does not have the ability to calculate or judge. If all calculations and judgments are made (such as judging whether the text box is empty, judging whether two passwords have been entered) Consistent) If the store executes it on the server side, the web page will be very slow, difficult to use, and put a lot of pressure on the server. Therefore, it is required to perform some simple operations in the browser. To judge, JavaScript is a A language that executes on the browser side.
(2) JavaScript and Java have no direct relationship. The only relationship is that JavaScript was originally called LiveScript. Later, it absorbed some features of Java and was upgraded to JavaScript. JavaScript is sometimes referred to as JS.
(3) JavaScript is an interpreted language and can be executed at any time without compilation. In this way, even if there are grammatical errors, the parts without grammatical errors can still be executed correctly.
JS development environment
(1) JavaScript and Jqery auto-complete function in VS.
(2) JS is a very flexible dynamic language, not as rigorous as static languages such as C#.
JS Getting Started
(1)
< ;script type="text/javascript">
alert(new Date().toLocaleDateString());
(2) JavaScript code is placed in In the <script> tag, <script> can be placed at any position such as <head>, <body>, and there can be more than one <script> tag. The alert function is a pop-up message window, and new Date() is to create an object of Date class, and the default value is the current time. <BR>(3) The <script> placed in <head> has been run before the body is loaded, and the <script> written in the body is executed one by one as the page is loaded. <BR>(4) In addition to declaring JavaScript in the page, you can also write JavaScript in a separate JS file and then introduce it into the page: <script src=”common.js” type=”text/javascript ”></script>. The advantage of declaring to a separate JS file is that multiple pages can be shared, reducing network traffic.
Event
(1) Click me
I won’t pop up anything
Click me
(2) JavaScript also has the concept of events, when the button is clicked
1)
2) Only the JavaScript in the href of the hyperlink requires "JavaScript:", because it is not an event, but treats "JavaScript:' like" http:", "ftp:", "thunder://", ed2k://, mailto:// are the same network protocols and are processed by the JS parsing engine. There is only this special column in href.
JS variable
(1) You can use double quotes or single quotes to declare strings in JavaScript, mainly to facilitate integration with HTML and avoid the trouble of escape characters.
(2) var i=10. ; //Declare a variable with the name i, pointing to the integer 10. Once it points to 10, i is of type int, alert(i);
(3) There are two types of null and underfined in JavaScript, and null represents the value of the variable. If it is empty, underfined means that the variable does not point to any object and has not been initialized.
(4) JavaScript is a weak type and cannot represent variables: int i=10. Variables can only be declared through var i=10; Unlike var in C#, it is not type inference like in C#
(5) In JavaScript, you can also use var directly instead of declaring variables. Such variables are "global variables", so unless you really want to use them globally. Variable, otherwise it is best to add var when using it.
(6) JS is dynamically typed, so var i=10;i="abc" is legal.
JavaScript
(1)
var sum = 0;
for (var i = 0; i sum = sum i;
}
alert(sum);
(2) If the code in JavaScript has syntax If an error occurs, the browser will pop up an error message. Checking the error message can help troubleshoot the error.
(3) JavaScript debugging, using VS can easily debug JavaScript. You need to pay attention to a few points when debugging:
1) IE debugging options should be turned on, Internet Options-Advanced, remove "Disable script debugging" Check the box in front of ".
2) Run the interface in debug mode.
3) Setting breakpoints, monitoring variables and other operations are the same as C#.
Judge variable initialization
(1) Three ways to judge whether variables and parameters are initialized in JavaScript.
var r;
if (r == null) { if (typeof (r) == "undefined") { if (!x) {
alert("null"); alert ("undefined"); alert("Not 🎜>(1) Method of declaring functions in JavaScript:
The code is as follows:
Copy code
The code is as follows:
(1)
The code is as follows:
(4)
The code is as follows:
(2)
Copy code
The code is as follows:
p1 .SayHello();
(3) The class name must be declared. function Person(name,age) can be regarded as declaring the constructor. Name and Age attributes are also dynamically added by the user.
Array() object
(1) The Array object in JavaScript is an array. First of all, it is a dynamic array, and it is a super complex like arrays ArrayList, Hashtable, etc. in C#.
(2)
Copy code
The code is as follows:
(3) No need to pre-set the size, dynamic.
Array() Exercise 1
(1) Array exercise, find the maximum value in an array.
The code is as follows:
}
var arr = new Array();
arr[0] = 20;
arr[1] = 10;
arr[2] = 34;
alert(MyMax(arr));
Array( ) Exercise 2
(1) Reverse the order of the elements of a string array, {3,9,5,34,54}{54,34.5.9.3}. Do not use the reverse function in JavaScript. Tip: Swap the i-th and length-i-1 to define the function.
Copy code
The code is as follows:
Array() Exercise 3
(1) Output a string array in |-divided form, such as: Han Yinglong|Try|Order. Do not use the Join function in JavaScript. arr.join(1) joins the array into a string using delimiters.
Dictionary usage of Array
(1 ) Array in JS is a treasure, not only an array, but also a Dictionary and a Stack.
(2)
var names = new Array( );
names["人"] = "ren";
names[" buckle"] = "kou";
names["hand"] = "shou";
alert(names ["人"]);
alert(names.人);
for (var k in names) {
alert(k);
}
( 3) Use it like Hashtable and Dictionary, and it is as efficient as them.
Simplified declaration of Array()
(1) Array can also have a simplified way
var arr=[3,4,5,6,7]; //Ordinary array initialization
This Arrays can be seen as a special case of names["人"]="ren";, that is, the keys are 0,1,2,3,4,5
(2) Simplified creation method in dictionary style
var arr={”tom”=30,”jim=”30};
Array, for and others
(1) For array-style Array, you can use the join method to concatenate it into a string.
var arr = ["tom", "jim", "kencery"];
alert(arr.join(",")); //join in JS is an array method, unlike .net which is a string method
(2 ) for loop can be used like foreach in C#.
for (var e in document) {
alert (e);
}

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.

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.


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

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment