Is it possible to access the previous scope of a function in Javascript? Or is it possible to automaticaly assign "this" to a parameter in typescript when calling a function? (so I have the previous scope)
for example: (a Function defined in my class Queryable)
Where(filter: (part: T) => boolean): Queryable<T> {
var ast = acorn.parse("(" + filter.toString() + ")"); ...
and I use it from outside:
var aa = new Queryable<ITest>();
var jj = "bb";
aa.Where(x => x.content == "aa" && x.bb.content == jj || x.form.Contains("Hallo"));
now inside my Where function, I need to get the value of "jj"
Mabey a little bit more Code helps:
class Queryable<T> {
Where(filter: (part: T) => boolean): IQueryable<T> {
var ast = acorn.parse("(" + filter.toString() + ")");
return null;
}
}
interface String {
Contains(par: String): boolean;
StartsWith(par: String): boolean;
EndsWith(par: String): boolean;
}
interface ITest {
content: string;
form: string;
href: string;
bb: ITest;
cc: ITest[];
}
function test() {
var aa = new Queryable<ITest>();
var jj = "bb";
aa.Where(x => x.content == "aa" && x.bb.content == jj || x.form.Contains("Hallo"));
}
test();
And inside the "Where" I need to access the Variables wich were used in the function in his parameter