07-24-2023, 06:32 AM
I am just starting out with javascript, trying to modify code I found in a book. `$.extend(item,this)` works just as I expect. But when I replace with `$.extend(item,this.defaults)` it does not correctly extend the item. What do I need to change in my formatting to fix that?
function addItem(details){
var item = {};
var name = details.name;
$.extend(item,this);
alert ("attempted to add new default"+this.defaults.type);
alert ("added default"+item.defaults.type);
return item;
};
function addItem(details){
var item = {};
var name = details.name;
$.extend(item,this);
alert ("attempted to add new default"+this.defaults.type);
alert ("added default"+item.defaults.type);
return item;
};