Skip to content

Instantly share code, notes, and snippets.

@thomaslang
Created March 19, 2009 21:29
Show Gist options
  • Save thomaslang/82075 to your computer and use it in GitHub Desktop.
Save thomaslang/82075 to your computer and use it in GitHub Desktop.
// this one works, calling Obj1.f(1) gives [1,3,5,7,9]
Obj1 = {
n: 10,
s: [],
f: function(m){
if(m<=this.n){
this.s.push(m);
this.g.g1(m+1);
}
},
g: function(m){
this.f(m+1)
}
};
// this one does not work, error: this.f is not a function source
Obj2 = {
n: 10,
s: [],
f: function(m){
if(m<=this.n){
this.s.push(m);
this.g.g1(m+1);
}
},
g: {
g1: function(m){
this.f(m+1)
}
}
}
/*
These examples are made up to illustrate the problem.
In the real code I don't see a way to replace this recursion.
So I would like to know if there is a way to make Obj2 work.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment