JavaScript Summary-what did you give me, and JavaScript Summary-
I. My thoughts
JavaScript has been learned, but what does it tell me?
First of all, it is a scripting language. As for what is a scripting language, we can treat it as a programming language used in the browser for the moment. It has its own set of syntaxes, which are common to other programming languages and have its own characteristics.
So what can it do? Everything in the world does not exist independently, and Js is no exception. It is combined with HTML, CSS, ASP. NET, AJAX, JQuery, and so on to implement the B/S program and create a more beautiful world. In this process, HTML displays information and CSS controls how to display. Js implements specific logic processing by combining other languages.
Since AJAX and JQuery have not been learned yet, they are not explained in detail. I hope I can have a better understanding of them and share them with you in the future.
2. Graphic Display
After completing the course, the editor drew a JS mind map based on the individual's needs, which is not detailed enough, but the main parts should all be available.
Iii. Difficulties 1. Closure
Description
A closure is a code block that can contain free (not bound to a specific object) variables. These variables are not defined in this Code block or in any global context, instead, it is defined in the environment where the code block is defined (local variables ). To put it simply: subfunctions can use local variables in the parent function. This behavior is called a closure.
Example (f2 is the closure ):
function f1(){ n=999; function f2(){ alert(n); } return f2; } var result=f1(); result(); // 999
Xiao Bian understanding: A closure is a function that can read internal variables of other functions. In Javascript, only the subfunctions in a function can read local variables. Therefore, you can simply understand the closure as a function defined in a function ". Therefore, in essence, closure is a bridge connecting the internal and external functions of a function.
2. null is different from undefined.
Null indicates "no object", that is, there should be no value.Typical usage:
(1) As a function parameter, it indicates that the function parameter is not an object.
(2) serves as the end point of the object prototype chain.
Undefined indicates "Missing Value", that is, there should be a value, but it is not defined yet.Typical usage:
(1) The variable is declared, but when no value is assigned, it is equal to undefined.
(2) When calling a function, the required parameter is not provided. This parameter is equal to undefined.
(3) The object does not have an attribute assigned a value. The value of this attribute is undefined.
(4) When the function does not return a value, undefined is returned by default.
Xiaobian understands:Null indicates that a value has been defined and is defined as "null". undefined indicates that there is no definition at all.
3. DOM
JavaScript uses the html elements in the browser, webpage documents, and webpages as corresponding built-in objects. Some of these objects exist as attributes of other objects, the relationships between these objects and their levels are referred to as the document object model of DOM (document object model.
Xiaobian understands:DOM is a framework, such as a DOM object in HTML, such as a DOM tree.
DOM objects can change HTML elements and attributes through their own attributes and methods, including controlling the display effect set by CSS.
Related reading: JavaScript tutorial
Difference between undefined and null
Closure