I pass an object literal to a function like this:
pre( {model:'MUserTry'} );
I then wish to augment it, but I end up writing over it like this.
pre : function( o_p ) {
o_p = {
result: '0',
page : {}
};
model is now gone as o_p is completely new
What is the best way to append object properties.
Do you have to explicitly define them now.
o_p.result = 0;
o_p.page = {};
or is there a function that will allow me to write out the object literal and combine them?
kind of like this
object1.push (object2 );
In your code the local variable o_p is redefined by the assigning:
You could merge your objects like this :
Alternatively, if you can use JQuery, you can just use the extend method: