Front-end Interview-----JavaScript plain chain and prototype __java

Source: Internet
Author: User

1. Constructor function


2. Five prototype principles

(1). All reference types (arrays, objects, functions) have object attributes that can be extended freely (except null)

(2). All reference types (arrays, objects, functions), all have

A _proto_ property, the property value is a normal object (implicit prototype)

(3). All functions have a prototype attribute, and the property value is also an ordinary object

(4). All reference types (array, object, function), _proto_ property value to the value of the prototype property of the constructor

(5). When trying to get a property of an object, if the object itself does not have this property, it will go to its _proto_ (that is, its constructor's prototype) to find


In this case, the F object does not alertname this property and then goes to his _prototype_ to look for the property in the prototype of his constructor.

3. Prototype chain


1. instanceof is used to determine how a reference type belongs to that constructor

The logic of the F instanceof Foo is:

F of the _proto_ layer up, can correspond to Foo.prototype

And try to Judge F instanceof Object.

2. About the process of describing a new object

Create a new object, this points to the new object, executes the code, that is, assigns a value to this, returns this

3 Prototype chain example (imitate Jqurey source code)





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.