myObj is an object which contains some parameters
myObj:
{
person: "John",
age: "20"
};
Now, I need to create a new object similar to original object (only slight changes to values), something like
newObj:
{
person: "John" + GetVal();
age: "20" + GetVal();
};
I tried something like:
var newObj = {};
angular.forEach(myObj,
function (value, key) {
_.extend(newObj, { key: value + GetVal() });
});
But this produces something like,
newObj:
{
key: "John" + GetVal();
}
But I am expecting an object
newObj:
{
person: "John" + GetVal();
}
Notice that key is taken as such but instead it should be the parameter name of the original object.
Any ideas how to achieve that ?
newObj.person = "John" + GetVal();?myObj. It could be anything. All I want is a similar object with every property's value modified.