Phillip Senn
Phillip Senn

Reputation: 47595

Using the $.extend plugin for jQuery on an undeclared variable

This page says to use:

var object = $.extend({}, object1, object2);

But I prefer to scope everything. So if I had a local scope explicitly declared, could I use:

var local = {};
$.extend(local.object, object1, object2);

instead of saying this:

var local = {};
local.object = $.extend({}, object1, object2);

Upvotes: 0

Views: 136

Answers (1)

Kim Tranjan
Kim Tranjan

Reputation: 4541

Have you ever tried this approach?

var local = { object: {} }; 
$.extend(local.object, object1, object2);

btw, I didn't see problem with the third approach.

Upvotes: 1

Related Questions