Properties in JavaScript objects (writable, configurable, enumerable, Value,getter,setter)

Source: Internet
Author: User

In JavaScript, the object consists of 3 attributes, namely, extensibility, class identifier, and attributes.

If the object's extensibility is false, the property cannot be added dynamically for the object. The object contains a property that is divided into accessors and values. Access attribute {get R () {/* function implementation */},set R () {/* Function implementation */}} Accessor property cannot save the value itself, set is equivalent to making changes to other properties in the object. The value of other properties can also be returned in get. The attribute value of the property is writable, configurable, value, enumerable. Accessor properties Use the Get,set property to replace both writable and value. In a browser that does not implement ES5, use __lookupgetter____lookupsetter__, the first parameter of the method is the property name, and the second parameter is function to view the get The Set property uses the __lookupgetter__ (' x ') __ parameter as the property name through Object.getownpropertydescriptor (object, property name), Object.defineproperty Use this method to add an attribute, you can configure the attribute value. If the property already exists, modify the attribute value. Object.defineproperties define multiple properties (object, {property name: {attribute value}}) Once the configuration is modified to false, you cannot modify the configuration again. The rest of the features are modified with the rule configurable to false, and writable rows can have true modified to false. The rest of the basic is immutable. the object. isPrototypeOf (a) Specifies whether an object has a on its prototype chain, and instanceof works like an object. propertyIsEnumerable (attributes) Whether the property is an enumerable object. hasOwnProperty (property) property is a property of its own in the keyword can detect whether an object and its prototype chain has a property var declared variable can not be deleted with the delete can be configured to false properties can also not

Properties in JavaScript objects (writable, configurable, enumerable, Value,getter,setter)

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.