JavaScript Advanced Programming (1)--javascript initial knowledge

Source: Internet
Author: User

I. Introduction to JavaScript

A historical review of 1.1 JavaScript.

JavaScript was born in 1995. At the time, its main purpose was to handle some of the input validation operations handled by the server side. Before JavaScript is available, the form data must be sent to the server side to determine

If a required entry is not filled in, enter an invalid value. Netscape Navigator wants to solve this problem through JavaScript. In an age when telephone dialing is widely used, waiting for verification to return is a patient

Behavior.

Since then, JavaScript has gradually become a feature of the browser that is common on the market. Today, JavaScript has long been used not just for simple data validation, but for the browser window and its internal

and the ability to interact in almost all areas. Today's JavaScript has become a full-fledged programming language capable of dealing with complex computations and interactions, with closures, anonymous functions, and even meta-programming capabilities.

Implementation of 1.2 JavaScript

A complete JavaScript should consist of three parts:

(1) Core (ECMAScript) (2) Document Object Model (DOM) (3) Browser object Model (BOM)

(1) ECMAScript:

The ECMAScript defined by ECMA-262 has no dependency on the Web browser, so it can be compatible with most browsers. Its components: syntax, type, statement, keyword, reserved word, operator, object.

(2) Dom

The DOM is an XML-based, extensible application programming interface for HTML. It maps the entire page to a multi-tiered node structure.

(3) Bom

It's a part of JavaScript, but it doesn't have the relevant standards. But it is customary to count all browser-specific JavaScript extensions as part of the BOM. Here are some extensions:

1) Popup new browser window function;

2) Move, zoom and close the function of the browser window;

3) Navigator object that provides browser details;

4) Provide the details of the page loaded by the browser location object;

5) Screen object providing detailed information of user's display resolution;

6) Support for cookies;

7) Custom objects such as the activexobject of XMLHttpRequest and IE;

Second, use JavaScript in HTML

1, using the <script> element, it has the properties:

(1) Async: Optional. Indicates that the script should be downloaded immediately, but should not interfere with other actions on the page, such as downloading additional resources or waiting for other scripts to load. Valid only for external script files.

(2) CharSet: Optional. Represents a character set that specifies code through the SRC attribute. Because most browsers ignore his values, they are seldom used.

(3) Defer: Optional. Indicates that the script can be deferred until the document is fully parsed and displayed after it is executed. Valid only for external script files.

(4) src: Optional. Represents the external script file to execute.

(4) Type: Optional. Represents the content type of the scripting language in which the code is written.

2, delay the script.

Defer= "Defer": indicates that the script will be deferred until the entire page is parsed and then executed.

3, asynchronous script.

Async: Indicates that the page is not waiting for the script to download and execute, and thus asynchronously loads the rest of the page, suggesting that the asynchronous script do not modify the DOM during loading.

  

Three, the basic concept.

3.1 is case-sensitive. 3.1.2 Identifier: Refers to the name of a variable, function, property, or parameter of a function. 3.1.3 Strict mode.

3.2 Data type: Undefined type: This value is undefined.

Null type: This value is null.

Boolean type: This value is a Boolean type.

Number type: This value is numeric.

String type this value is a literal.

Object type: This value is an object or is null.

3.3 Understanding Parameters

The parameters of the ECMAScript function differ from the parameters of the functions in most other languages, and the ECMAScript function does not mind passing in the number of arguments, or what data type the parameter is passed in. Other words:

Even if you define a function that only receives two parameters, the wild may not necessarily pass two arguments when calling this function. You can pass one, three, or even pass parameters, and the parser will never complain. The reason for this is that

The parameters in the ECMAScript are represented internally by an array. The function always receives this array, regardless of which parameters are included in the array (if any). If the array does not contain any elements,

It doesn't matter if you have more than one element. In fact, the parameter array can be accessed through the arguments object in the body of the function to get each parameter passed to the function.

  

3.4 No Overloads

If two functions with the same name are defined, the name belongs only to the post-defined function. That is, the function defined later overrides the function defined first.

4.1 Values for base types and reference types

The ECMAScript variable may contain values for two different data types: the base type value and the reference type. A primitive type value refers to a simple data segment, whereas a reference type value refers to an object that may consist of multiple values.

When assigning a value to a variable, the parser must determine whether the value is a base type value or a reference type value. Basic data type: Undefined, NULL, Boolean, number, and string. These 5 basic

A type is accessed by value, because the actual value saved in the variable can be manipulated.

The value of a reference type is an object that is saved in memory. Unlike other languages, JavaScript does not allow direct access to the in-memory location, i.e. it cannot manipulate the object's amount of memory directly, while manipulating the object

In fact, a reference to an object is manipulated instead of an actual object, and for this reason the value of the reference type is accessed by reference.

    

JavaScript Advanced Programming (1)--javascript initial knowledge

Related Article

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.