Kevin Powell - CommunityKP-C
Kevin Powell - Community13mo ago
22 replies
snxxwyy

class logic questions

Hey, a few questions about the logic in classes-

1) If i define a this. variable inside of a function, why can i use it outside of the function globally within the class? I understand it's because it uses this. and that refers to the object but that defies the regular logic of how that would work, is that specific functionality for this or classes? (example: https://codepen.io/deerCabin/pen/xbKYQPG)

2) Why don't i need to use
const
or var when defining this. variables?

3) Why don't i need to use the function keyword when defining functions within classes?

Thanks in advance.
Was this page helpful?