ECMAScript 5 also defines a object.defineproperties () method because there is a high likelihood that no object defines multiple properties. This method allows you to define multiple properties at once by using a descriptor. This method receives two object arguments: The first object is the object whose properties are to be added and modified, and the properties of the second object correspond to the property one by one to be added or modified in the first object. For example:
var book = {};object.defineproperties (book,{ _year:{ value:2004 }, edition:{ value:1 }, year:{ get:function () { return this._year; }, set:function (newvalue) { if (newvalue >2004) { this._year = newvalue; This.edition + = newValue-2004;}}} );
The above code defines two data attributes (_year and edition) and one accessor property (year) on the book object. The final object is the same as the object defined in the previous section. The only difference is that the properties here are created at the same time.
Browsers that support the Object.defineproperties () method are ie9+, ff4+, safari5+, opera12+, and Chrome.
6.1.2 Defining multiple properties