Why are my constructor properties returning undefined in my prototype function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why are my constructor properties returning undefined in my prototype function?

I have a class and constructor in it. I’ve then created multiple objects with it and made a function on the prototype that executes, but it returns the properties it refers to as undefined and I’m not sure why. I tried moving the prototype after the objects are declared but that didn’t work. Also, does it matter if a function is written on the prototype before or after the objects are declared? You can see the prototype function executed as an alert pop up. https://code.sololearn.com/W6ZQjmYIRj9x/?ref=app

6th Jan 2019, 7:49 PM
Thomas Czernek
Thomas Czernek - avatar
1 Answer
+ 9
If you switch the farewell prototype from arrow function to regular function it works https://teamtreehouse.com/community/does-arrow-function-syntax-works-for-prototype
6th Jan 2019, 8:19 PM
Burey
Burey - avatar