- Home /
public private and static variables in js
Hi, Can someone tell me the difference between public, private, and static variables? When should they be used. I actually believe i understand static vars. But not the use of public and private.
Comment
Best Answer
Answer by Mike 3 · Mar 21, 2011 at 05:13 PM
Public members are accessible from other classes
Private members are accessible only from within the class itself
Static members belong to the type/class instead of an instance - i.e. there is only one of them shared between all instances of a class
You can also use protected and internal - protected members are available from inheriting classes, internal works for other classes in the same assembly. These two probably aren't as interesting for you than the others though