JavaScript Phase Summary

Source: Internet
Author: User

  JavaScript is a scripting language, mainly used in the browser, to achieve the Web page of the Document object operation and some user interaction action processing. Li Tinghui Teacher said 100 episodes video, a more thorough analysis of JavaScript, as a beginner feel the teacher told a lot of things. This is the lack of a holistic view of the performance, not in the overall analysis of JavaScript, just a plunge into the video can not extricate themselves, so that the knowledge is trivial, no connection. But the trivial knowledge in the video to organize to find:

JavaScript is divided into three parts: ECMAScript, DOM, BOM.

  ECMAScript is actually a syntactic and semantic standard for scripting languages that defines all the properties, methods, and objects of a scripting language. These basic knowledge is no longer said, here is the main mention of how JavaScript inheritance mechanism is implemented.

As an object-oriented language, JavaScript must also support inheritance mechanisms, but his inheritance is slightly different from other languages.

  1. Object posing

The constructor uses the This keyword to assign values to all properties and methods. Because the constructor is just a function, you can make the ClassA constructor method called the ClassB method, and then call it. CLASSB will receive the properties and methods defined in the ClassA constructor method.

In this way, variable B contains the method defined in ClassA.

function ClassA (name) {            this.name=name;            This.getname=function () {                return this.name;            }        }                function ClassB (Name,password) {this            . Classa=classa;            This. ClassA (name);            Delete this. ClassA;                        This.password=password;            This.getpassword=function () {                return this.password;            }        }                var b =new ClassB (' wwww ', ' 1123 ');        document.write (B.getname ());


In addition, we can also use the call () and the Apply () method to implement the object impersonation, no longer an example.

 2. Prototype chain

The principle is that the constructor of an object can inherit a method from another object, and after it creates a prototype object, all other new objects can be built based on the prototype object. The prototype itself does not inherit properties from other prototypes or constructors, and the properties are inherited from the actual object.

function person (name) {            this.name=name;        }                Person.prototype.getname=function () {            return this.name;        }                function User (name,password) {            this.name = name;            This.password = password;        }                User.prototype = new Person ();        User.prototype.getpassword=function () {            return this.password;        }


Explain:

User.prototype = new Person (); How is this sentence understood? User is a reference to the user object constructor, and new person () creates a person object using the person constructor and then resets the prototype of the person object to the result of the operation. That is, the new user object will have all the methods of the person object each time new user ()

DOM--   Object document model, which is an application interface (API) for HTML and XML. The DOM will plan the entire page into a document composed of node hierarchies. Each part of the HTML or XML page is a derivative of a node, and the DOM API makes it easy to delete, add, and replace nodes. Through this mechanism, we have unprecedented control over the content and structure of the document, which greatly improves the interactive ability of the page.

HTML DOM Tree Chart:

  A BOM(Browser object model) that can be accessed and manipulated by the browser window. Using the BOM, we can move the window, change the text in the status bar, and perform other actions that are not directly related to the content of the page.

This includes browser detection, because each browser has its own unique extension, so in the development phase to judge the browser is a very important step. Although browser developers put a lot of effort into the public interface, trying to support the most common public functions, but in reality, the differences between browsers, as well as the "quirks" of different browsers is very much, so browser detection is a remedial measure, but also an effective development strategy. As a developer, we should consider the problem comprehensively, improve the robustness of the system, reliability!

  Summarize:

ECMAScript describes the syntax and basic objects of the JavaScript language;--core

The DOM describes the methods and interfaces for handling Web page content;

The BOM describes the methods and interfaces that interact with the browser.

JavaScript learning has only just begun.

JavaScript Phase Summary

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.