extend(setting: Object, extSettings: Object, replaceAll: Boolean, recursive: Boolean, arrayAsPrimitive: Boolean);
setting. Object to extend.
extSettings. Object whose members are used to extend another object.
replaceAll. Indicates that matching members are replaced. If this parameter is True matching members are rewritten, otherwise they are not. This is an optional parameter, by default its value is not defined.
recursive. Indicates recursive iteration through object members. If this parameter is True object members are recursively iterated through, otherwise they are not. This is an optional parameter, by default its value is not defined.
arrayAsPrimitive. Indicates that specified arrays are primitives and must be fully replaced. If this parameter is True the arrays are regarded as primitive types and are fully replaced. This is an optional parameter, by default its value is not defined.
The extend method extends specified object with members of another object.
The method returns an array.
To execute the example, add a link to PP.js scenario file to HTML page. Determine two objects and extend the first one with members of the other one:
// Determine an extended object var chart = { chartType: "pie", editMode: 0, }; // Determine the object, which members are used to extend the first object var chartView = { editMode: 2, selectionEnabled: True, options: "selected" }; // Get all available values of object members var getProperties = function (obj) { var result = ""; for (var i in obj) { result += obj[i]; result += " " }; return result; } console.log("Values of the "chart" object members: " + this.getProperties(chart)); console.log("Values of the "chartView" object members: " + this.getProperties(chartView)); // Extend the first object by means of the second one PP.extend(chart, chartView, True, True, False); console.log("Values of members of the "chart object extended by means of the "chartView" object: " + this.getProperties(chart));
After executing the example the browser console displays values of the chart object members extended with member of chartView:
Properties of the chart object: pie 0
Properties of the chartView object: 2 True selected
Properties of the chart object extended with chartView: pie 2 True selected
See also: