JavaScript Learning Notes (vii)----object-oriented programming

Source: Internet
Author: User

1. Properties of an Object

There are two types of properties in ECMAScript: Data properties and accessor properties.

1) Data properties: There are 4 properties that describe their behavior.

    • [[writable]]: Indicates whether the value of the property can be modified, by default, True.
 var  person = {};alert ( typeof  person); // object    Object.defineproperty (person, "name" ,{  Writable:     false   Span style= "color: #000000;" >    value: " Yoyo "}); alert (person.name);  // yoyo  person.name = "Anne" ;alert (Person.name);  // yoyo  
 var  person = {};alert ( typeof  person); // object  Object.defineproperty (person, "name" ,{  Writable:      true     ,   value :  "Yoyo"  // yoyo  person.name = "Anne" ;alert (Person.name);  // anne  
    • [[Configurable]]: Indicates whether the property can be modified from a new definition by deleting the attribute from the delete, or whether it can modify the attributes of the property or modify the property to an accessor property. The default value is true.
var person = {};object.defineproperty (person,"name", {    configurable:false ,    value:"Yoyo"//YoyoDelete//  Yoyo
var person = {};object.defineproperty (person,"name", {    configurable:true ,    value:"Yoyo"//YoyoDelete//  Undefined
    • [[[Enumerable]]: Can return a property by for-in loop, default is True
    • [[Value]]: Contains the data value for this property. When reading a property value, read from this position, and when writing the value of the property, save the new value in this position. The default value is undefined.

JavaScript Learning Notes (vii)----object-oriented programming

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.