I want to get a value from class Check but always get undefined
.
class Check {
static testget() {
let tester = 1;
return tester;
}
}
window.onscroll = function() {
const test = new Check();
console.log(test.testget);
};
It should show 1
on console, but I always get undefined
.
I will request you to spent some time on Classes: Static methods.
Since the member (testget) is static, you can not access that with an instance (test) of the class, use class name. Also specify ()
after function name to invoke the function:
console.log(Check.testget());
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments