Recently while solving a problem, I came across a requirement to create a property in a JavaScript class, which needs to be shared by all the object instances. In the programming world, these types of properties are called Static Properties. There are various scenarios when you need a static member property: When counting number of object instances created from a particular class When logging some information at the class level instead of object instance level, etc. To create a static property, you should know two important things: A JavaScript class cannot have a member property. You can only create it using a constructor Like the function constructor, a JavaScript class also has a prototype Well, if you are a champion of prototypes, you must have guessed the answer in your mind by this time. Any way, let us move forward to see the implementation, Read full article on the Infragistics blog
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
JavaScript,Javascript,prototype,static variable
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
JavaScript,Javascript,prototype,static variable
No comments:
Post a Comment