, JavaScript,

JavaScript is an interpreted execution script language. It is a dynamic type, weak type, prototype based language, built-in support type, and it follows the ECMAScript standard. Its interpreter, known as the JavaScript engine, is widely used as a part of the browser and is widely used in the client's scripting language, which is mainly used to add dynamic functions to HTML.

almost all mainstream languages can be compiled into JavaScript, and then can be executed on browsers on all platforms. This also reflects the importance of JavaScript and its importance in Web development. For example, Blade: an extension of Visual Studio, which can transform C# code to JavaScript, Ceylon: a modularized and static type JVM language that can be compiled to JavaScript.

JavaScript is a language that can run at the front end and back stage at the same time, for example, Node.js is a JavaScript running environment based on Chrome V8 engine (similar to Java or.NET). Node.js uses an event driven, non blocking I/O model to make it lightweight and efficient.

1.1, JavaScript

ECMAScript

, describes the language syntax and the basic objects, such as type, operation, process control, object oriented, abnormal etc.. The

document object model (DOM) describes the methods and interfaces for dealing with the content of a web page. The

browser object model (BOM) describes the methods and interfaces that interact with the browser.

JavaScript is made up of objects and everything is an object.

1.2, JavaScript scripting language features

a), interpretive scripting language. JavaScript is an interpretive scripting language, and languages such as C, C++ are compiled and executed first, while JavaScript is interpreted line by line in the process of running the program.

is based on objects. JavaScript is an object based scripting language that can not only create objects but also use existing objects.

b), simple. JavaScript language uses weak type variable types, and does not make strict demands on the data type used. It is a script language based on Java basic statement and control, and its design is simple and compact.

c), dynamic. JavaScript is an event driven scripting language that does not need to respond to user input without a Web server. When accessing a web page, mouse can click, move up and down and move windows in web pages. JavaScript can directly respond to these events.

d), cross platform. The JavaScript scripting language is not dependent on the operating system and requires only the support of the browser. Therefore, a JavaScript script can be used to any machine when it is written. On the premise, the browser on the machine supports JavaScript script language. At present, JavaScript has been supported by most browsers.

two, ECMAScript (JavaScript

2.1, ECMAScript

, ECMAScript

1) definition is a standard (European Computer Manufacturers Association), JavaScript is a realization of it, others including ActionScript (Flash

2), ECMAScript script) can provide the key different host environment script programming ability, namely ECMAScript and specific host environment binding, such as JavaScript host environment is the browser, AS host environment is Flash.

,

3, ECMAScript) describes the following contents: grammar, types, statements, keywords, reserved words, operators, etc. the object

2.2,

data types use the VaR keyword to declare a variable in JS, the type of the variable according to the assignment to decide (dynamic type). Data types in JS are divided into original data types (5 types) and reference data types (Object types).

1) 5 kinds of original data types: Undefined, Null, Boolean, Number, and String. It is important to note that the string in JS belongs to the original data type.

2) typeof operator: see variable types of variables or values of call typeof operator returns one of the following values:

    • undefined? If the variable is of type Undefined
    • boolean? If the variable is of type Boolean
    • < div>number? If the variable is of type Number
    • string? If the variable is of type String the
    • object? If the variable is a reference type or Null type

3) to solve the problem of /p>

4 < reference type judgment by instanceof operator) null is considered a placeholder, the typeof operator for the null value return "object".

5) the primitive data types and reference data types of variables stored in the memory as follows:

memory

6) JS in the type definition: a set of values. For example, there are two values of the Boolean type: true, false. Both the Undefined and the Null types have only one value, undefined and null, respectively. The

Null type has only one value, that is, null; the Undefined type has only one value, that is, undefined. Both null and undefined can be used as a literal (literal) in the JavaScript code. The

null is related to an object reference, representing an object reference that is empty or nonexistent. When it is declared that a variable does not assign a value to it, its value is undefined. The value of

undefined will appear in the following case:

gets an attribute from an object, if the object and its object in the prototype chain do not have the attribute, the value of this property is undefined. The return value of a

function is undefined if it does not return a value to its caller explicitly through return. One special case is when new is used. Function in

JavaScript can declare any form parameter. When the function is actually invoked, if the number of incoming parameters is less than the declared formal parameter, the value of the extra formal parameter is undefined.

 example: 

< DOCTYPE html> <!; html> < head> < meta charset= "UTF-8" > < title> < /title> < /head> < body> < script> //js var user = {name: "Jacky Cheung" address: "Chinese Hongkong"}; console.log (user.age); / / attribute access object, defined var I; console.log (I); / / variable unassigned (N1) f function (N1) {console.log}; VAR (result=f); / / console.log parameter unassigned (result); / / when the function does not return a value for undefined < /script> < /body> < /html>

results:

"src=" http://files.jb51.net/file_images/article/201801/2018010717111961.png ">

on null and undefined have some interesting characteristics:

, if the typeof operator is used for variables whose value is null, the result is object,

, and typeof for undefined value, the result is undefined.

typeof null = "object" //true; typeof undefined = "undefined" //true null = undefined //true, but null //true

undefined! =

 example: 

< DOCTYPE html> <!; html> < head> < meta charset= "UTF-8" > < title> < /title> < /head> < body> < script> //js var user = {name: "Jacky Cheung" address:, "China Hongkong"}; console.log (typeof (user)); console.log (typeof (null)); console.log (typeof (undefined)); console.log (user.name); console.log (user.age); if (user.age) {console.log (user.age);}else{console.log ("age properties");} / / false var I; console.log (!! ""); console.log (0; console.log (!!)!! (+0); console.log -0; console.log (!!)! NaN (console.log);!!! (null); console.log undefined; console.log!!) (typeof (I)); console.log (!! I); console.log (false); / / if not for the digital is Not a Number, console.log (isNaN ("Five"); console.log (isNaN) ("5")); < /script> < /body> < /html>

results:

"src=" http://files.jb51.net/file_images/article/201801/2018010717111962.png ">

7

),

,

8, ===

and

JavaScript) = two is equal to the value judgment operator = = and = = =. Compared the two, = = will do some conversion; and do = type conversion, equal to accept more stringent.

=== will is a type of

course and the corresponding ==

! =

= = = and! Try to use and do not use the ==

 console.log (5 ==5); //true console.log (5 ===5); //false console.log ("5"! =5); //false console.log ("==5 5"! //true

;

2.3), local and global variables

statement in the function of variables can only be used in the function, when you exit the function, the variable will be released, these variables are called local variables. Since each local variable is only valid in their respective functions, you can use the same variable in different functions.

, if the variable is declared outside the function, all the functions in the page can be used. After the global variables are declared, they begin to take effect. When the page is closed, the variable will fail.

note: in the JS language, the variables declared in the code block belong to the global variable.

JavaScript is a language that does not require strict data type variables, so it is not necessary to declare the type of every variable. Variable declarations are not necessarily required, but declaring before using variables is a good habit. The VaR statement can be used for variable declarations. Such as: VAR men = true; / / men values stored in the Boolean type. The

variable named

JavaScript is a case sensitive language, so it is not the same to name a variable as best and to name it as Best.
in addition, the name of the variable length is arbitrary, but must follow the following rules:

  • 1. first character must be a letter (case insensitive), or an underscore (_) or a dollar sign ($).
  • 2. subsequent characters can be letters, numbers, or the underscore the dollar sign.
  • 3. variable name cannot be reserved.

can not use VaR to define a variable, but the variable that defines it is a global variable.

 example: 

< DOCTYPE html> <!; html> < head> < meta charset= "UTF-8" > < title> < /title> < /head> < body> < script> function a (VaR) {n1=1; n2=2; / / not using VAR N2 statement,


This concludes the body part

This paper fixed link:http://www.script-home.com/javascript-learning-summary-1-ecmascript-bom-dom-core-browser-object-model-and-document-object-model.html | Script Home | +Copy Link

Article reprint please specify:JavaScript learning summary (1) ECMAScript, BOM, DOM (core, browser object model and document object model) | Script Home

You may also be interested in these articles!