DEV Community

LG
LG

Posted on • Edited on

Visibility modifiers, keyword of static – all in one of JavaScript ES5 standard you need for today ! [2021-12-30] (2 ed.)

Before ES6 came into Object Oriented Programming (OOP) field of JavaScript, we could only dream for a standardized PHP class like syntax , we've got one the moment ES5 been updated to ES6 in 2015 . Still, some people (including myself) tend to keep tactility sense of the syntax into hands (in charge), rather than an easy legible candy a.k.a. so called syntactic sugar of the class pattern presented in ES6. It means we can still preserve all the features of ES6 such visibility modifiers (protected, private) also define methods as static if needed rather than instance-related one. All these are still possible in ES5 which we will see in a minute. Of course ES6 class syntax will probably always remain per recommendation to use , although programmers who want to preserver "feeling" of the code may still be suggested to revise this empowered initially by @obscerno comment :

HOW TO : open console, examine the code & its output as well:

NOTE : As this is 2 ed. I have tried to use protected as variable (member) name within source code , whereas codesandbox IDE red it out . It appears ESnext (2022+) reserved it already , I'll guess there are a shiny future for ECMAScript (JavaScript) is coming for sure , so stunned , JavaScripters !


To conclude : Instead of using this for production, use this as a background of what really is going on in terms of Javascript ES6 class syntax under the hood. I will repeat myself that ES6 class syntax will remain per recommendation to use. That's all for now. If any suggestion or typo found, please leave a comment below. Thank you for reading! :)


Useful references

Top comments (0)