1. What is Object. create? Object. create (proto [, propertiesObject]) is a new object creation method proposed in E5. the first parameter is the prototype to be inherited. If it is not a subfunction, you can pass a null parameter, and the second parameter is the property of the object... syntaxHighlig 1. object. what is create? Object. create (proto [, propertiesObject]) is a new object creation method proposed in E5. the first parameter is the prototype to be inherited. If it is not a subfunction, you can pass a null parameter. The second parameter is the object's attribute descriptor. this parameter is optional. For example, copy the code function Car (desc) {this. desc = desc; this. color = "red";} Car. prototype = {getInfo: function () {return 'A' + this. color + ''+ this. desc + '. ';}}; // instantiate object using the constructor functionvar car = Object. create (Car. prototype); car. color = "blue"; alert (car. getInfo (); copy the code to A blue undefined. 2. propertiesObject parameter description: (both are false by default) Data Attribute writable: can write retriable: can be deleted, can be written? Modified enumerable: Can I use for in enumeration value: value access attribute: get (): Access set (): set 3. Example: See the example to know how to use it. Copy code Yupeng's document
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.