why does my functions returning "undefined"

Jojo

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.

Mamun

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.

edited at
0

Comments

0 comments
Login to comment

Related

why does my nodejs function returning undefined?

Why are functions returning undefined?

why is my object returning undefined?

Why is my promise returning undefined?

Why is my intersectionObserver returning my querySelect as undefined?

Why is my variable tabledata returning undefined?

Why is my recursive function returning undefined?

Why is my variable returning undefined in javascript?

Why is my reducer returning undefined, React TypeScript

Why is my function returning an array with undefined as items?

Why my functions is not returning a component? React

Why are my path functions not returning any images

Why does useState is returning undefined in output?

Why does my c++ code keep returning 'undefined reference to' one of my constructors when I try to compile?

Why is my get request returning undefined in my image file tree?

Why is my axios post returning undefined in my functional component?

Why is my function returning undefined along with the reversed string

Why is my email check variable returning an error as undefined

Why is my function returning undefined despite printing out correctly

Why is my variable returning as 'undefined' despite being set a value?

why my Nodejs / NestJs promise is returning undefined to variable in second function?

Why is my RegExp.prototype.exec() returning array of undefined?

Why does flowtype think my variable is undefined?

Why does my function always return undefined?

Why does undefined get added to my string?

Why does my recursive function return "undefined"?

Why are my various CASE WHEN functions returning the same values?

why does javascript skip some of my functions?

Why does Appbase return 'undefined' before returning the correct item?