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.

more ▼

asked Mar 21, 2011 at 04:59 PM

avatar image

72 29 22 29

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Mar 21, 2011 at 05:13 PM

avatar image

Mike 3
34.4k 25 151 318

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Mar 21, 2011 at 04:59 PM

Seen: 7150 times

Last Updated: Mar 21, 2011 at 04:59 PM