x


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

vdizzle gravatar image

vdizzle
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

Mike 3 gravatar image

Mike 3
33.3k 21 93 299

(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

By RSS:

Answers

Answers and Comments

Topics:

x560
x462
x131
x56

asked: Mar 21, 2011 at 04:59 PM

Seen: 6554 times

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