Detailed description of javascript Object scalability, and javascript scalability

Source: Internet
Author: User

Detailed description of javascript Object scalability, and javascript scalability

Scalability in javascript objects refers to whether new attributes can be added to objects. All built-in and custom objects can be displayed as extensible objects. For host objects, it is determined by the javascript engine.

The following functions are used to set object Scalability:

1. Object. isExtensible (Object); check whether the Object can be extended.

2. Object. preventExtensions (Object) sets that an Object cannot be expanded, that is, a new attribute cannot be added. However, if a new attribute is added to the prototype of the Object, the Object also inherits this attribute.

3. Object. seal (Object); in addition to setting the Object's non-expandable attributes, you can also set its own attributes to unconfigurable and cannot delete or configure the Object. You can still set its existing writable attributes.

4. Object. isSealed (Object); check whether the Object is closed.

5. Object. freeze (); more strictly lock the Object (freeze ). Except for setting the object to non-extensible, the attribute is set to non-configurable, and all its own attributes are set to read-only. (if the object storage attributes have the setter method, the memory attributes are not affected, you can still assign values to them through attributes ).

6. Check whether the Object is frozen by Object. isFrozen.

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.