x


Before updating to Windows 10 you may need to return your Pro license. More information here

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

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

avatar image

Mike 3
34.6k 28 156 319

(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:

x624
x525
x152
x57

asked: Mar 21, 2011 at 04:59 PM

Seen: 7207 times

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