overrideObject(target: Object, source: Number, p: String);
target. Object to rewrite.
source. Object used to rewrite another object.
p. Name of the property to rewrite.
The overrideObject method rewrites value of specified property of an object with value of the same property of another object.
To execute the example, add a link to PP.js scenario file to HTML page. Create two objects, and overwrite value of the first object chartType property with values of corresponding property in the second array:
// Determine object to replace var chart = { chartType: "pie", editMode: 0, options: "selected" }; console.log("The value of the chartType property of the source object: " + chart.chartType); console.log("The value of the editMode property of the source object: " + chart.editMode); // Determine the object, which members are used to extend the first object var chartView = { chartType: "line", editMode: 2, selectionEnabled: True, }; PP.overrideObject(chart, chartView, "chartType"); console.log("The value of the chartType property of the overridden object: " + chart.chartType); console.log("The value of the editMode proeprty of the overridden object: " + chart.editMode);
After executing the example the browser console displays value of the chartType property for the initial and overwritten first object ( value of the editMode property is given for comparison):
Value of chartType property for initial object: pie
Value of editMode property for initial object: 0
Value of chartType property for overwritten object: line
Value of editMode property for overwritten object: 0
See also: