I am trying to add an .each() method to a JS class declaration. However, I think the two this
keywords are conflicting. Attempts to return the class variable using this
returns undefined
.
class MyClass{
constructor(parameterA, parameterB){
this.parameterA = parameterA;
this.myClassMethod = this.myClassMethod.bind(this);
}
myClassMethod(){
$('.class').each(function(){
console.log(this.parameterA); //Returns undefined
}
}
}
var test = MyClass(parameterA, parameterB);