Reputation: 19251
I am trying to do something like
(function( skillet, $, undefined ) {
skillet.global = {
names: {
first: 'abe',
last: 'watson'
},
addresses: {
home: 'blah'
}
}
}( window.skillet = window.skillet || {}, jQuery ));
So that I can access like
skillet.global.names.first();
skillet.global.address.home();
But I keep getting errors ? How can I go about fixing this
Upvotes: 0
Views: 100
Reputation: 16605
You are calling first
and home
as if they were functions; yet you have defined them as object properties.
Calling skillet.global.names.first
would (if in an alert) show abe
, if you need to define them in functions, you need to use the correct function declaration, i.e.
names: {
first: function() {
return 'abe';
},
last: 'watson'
},
addresses: {
home: function() {
return 'blah';
}
}
Upvotes: 6
Reputation: 25135
change skillet.global.names.first();
to skillet.global.names.first;
change skillet.global.address.home();
to skillet.global.addresses.home;
Upvotes: 3