One of the many Object Oriented approaches will be quite effective here (there are many other ways):
Code:
var set = function () {
set.thing1 = 'thing1';
func ();
},
func = function () {
alert (set.thing1);
};
set ();
Here's another way:
Code:
var Set = function () {
this.thing1 = 'thing1';
this.func ();
};
Set.prototype.func = function () {
alert (this.thing1);
};
new Set ();
Or:
Code:
var Set = function () {
this.thing1 = 'thing1';
func (this);
};
var func = function (s) {
alert (s.thing1);
};
new Set ();
Or:
Code:
var Set = function () {
this.thing1 = 'thing1';
};
var func = function () {
alert (a_set.thing1);
};
var a_set = new Set ();
func ();
Or:
Code:
var set = {
thing1 : 'thing1',
func : function () {
alert (this.thing1);
}
};
set.func ();
Bookmarks