JavaScript Object-oriented learning--3

Source: Internet
Author: User
Tags hosting

Introduction to the Object basics:

1. The object is the basic data type of JavaScript. In Java, object is the base class for all objects, and in JavaScript as well, object is the base class for all objects, and object's own properties and methods are reflected in all objects, except that different classes have different overrides for methods.

2. JavaScript objects are dynamic-you can add properties or delete properties-but they are often used to emulate static objects and "struct" (struct) in statically typed languages. Sometimes they are also used as a collection of strings (ignoring values in name/value pairs).

3, except string, number, true. False. In addition to null and undefined, the values in JavaScript are objects. Although strings, numbers, and Booleans are not objects, their rows are very similar to immutable objects.

4. The object is mutable, and we manipulate the object by reference, not by value. If the variable x is a reference to an object, the execution code yar y two x; the variable y is also a reference to the same object, not a copy of the object. Modifying this object through the variable y also affects the variable x. The most common uses of objects are:

Creates (create), sets (set), finds (query), deletes (delete), detects (test), and enumerates (enumerate) its properties.

Properties of the object:

1, the attribute includes the name and the value. The property name can be any string that contains an empty string, but there cannot be two properties with the same name in the object. The value can be any JavaScript value, or (in ECMAScript 5) can be a getter or setter function (or both). In addition to the name and value, each attribute has some value associated with it, called the property attribute:

Writable (veritable attribute), indicating whether the value of the property can be set.

An enumerable (enumerable attribute) that indicates whether the property can be returned through a for/in loop.

Configurable (configurable attribute), indicating whether the property can be deleted or modified.

Before ECMAScript 5, all properties created by code to an object are writable, enumerable, and configurable. These features can be configured in ECMAScript 5

In addition to the include attribute, each object also has three related object attributes (attribute):

The object's prototype (prototype) points to another object, and the properties of this object inherit from its prototype object.

The class of the object is a string that identifies the object type.

The extended tag (extensible flag) of the object indicates whether a new property can be added to the object (in ECMAScript 5).

2. Use these terms to differentiate between three types of JavaScript objects and two types of attributes:

built-in objects (native object) is an object or class defined by the ECMAScript specification. For example, arrays, functions, dates, and regular expressions are built-in objects.

Host Object (host object) is one defined by a hosting environment (such as a Web browser) that is embedded by the JavaScript interpreter. The Htmleiement object in client JavaScript that represents the structure of a Web page is a host object. Since the method defined by the hosting environment can be used as a normal JavaScript function object, the host object can also be used as a built-in object.

Custom Objects (User-defined object) are objects created by running JavaScript code.

own Property (own property) is an attribute that is defined directly in an object.

Inheritance Properties (Inherited property) is an attribute defined in the object's prototype object.


JavaScript Object-oriented learning--3

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.