Why OOJS (Object Oriented Javascript)?
Hi,
Hope you are doing well !
I am a beginner in JS programming and was going through the basics. This story is all about the new experiences which I am getting day by day learning. Till now as I understand JS is being used widely to perform a different type of executions based on browsers event.
In most of the institutions (I could be wrong if they have updated their curriculum ), JS is being taught as a language to handle the browser-based events only. For example:- onclick|onmouseover|onload|ondrop etc.(for list of events please visit W3schools HTML events page).
Yes, that kind of information would definitely help you to work with other backend driven language like JAVA|ASP.net|ROR etc. But that’s not the whole truth, JS is having the full capability to perform all tasks as other languages do. Hence, please accept the fact that JS is a programming language which is being used in different flavours Angular|React|Backbone etc.
When I say JS as a programming language, it means It can be used as front-end(client side) & backend(server side) as well.
Now the real question is why it’s called as OOJS?
As we know the most useful programming languages follow the OOPS concept and similarly JS was designed in the same fashion with a little bit different approach. Unlike others, JS follows the prototype based OOPS concept.
When we say prototype based OOPS, it means there would not be any concept of classes and then the creation of instances as their Object. Here we create an Object and define their initial data behaviour by creating a prototype and later we use that object to create another instance. By this way, it automatically gets the data and behaviour of earlier created prototype. Hence, even to create a new prototype you need an Object first and for this JS helps you by giving you the generic object — JS Object. In other words, we can say that everything in JS belongs to generic JS Object and Object.prototype.
will update the references and more details soon…