Wednesday, 23 August 2017

javascript - Private static variable?

Is it possible to create "private static" variables in JavaScript similar to Java?




My scenario is that I need to retrieve a data point from server and save in the static variable, so that my function which uses this need not make server call every time its called.



I also need the data once fetched and copied to variable not be read outside that class as I need it to be secure, want to have it private. I have read that to achieve private variable we use scope functionality in JavaScript but I also need it to be static.



Can this be achieved?

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...