Reputation: 1482
Recently I ran into some code that basically looks like :
class A {
constructor(opts) {
this.a = {};
}
for(x, y) {
...
return {
async check(id) {
...
}
};
}
...more method definitions in the class
}
I'm wondering how its possible to put a for loop inside a class definition . I can see that it is returning a function, but does this mean that the returned function becomes a member function for the class?
Upvotes: 0
Views: 54
Reputation: 8589
It's not a for loop, it's a method named 'for'.
More or less equivalent to
A.prototype.for = function for( x, y ) {
...
return {
async check(id) {
...
}
};
}
Upvotes: 3