JavaScript – Writing simple prototypes JS

JavaScript is really an interesting language – the more you code / learn it, the better it comes and the more interesting it turns out to be. I will preset a simple way of using prototypes with JS. Pretty much, if you build a prototype function to an object, then you may give this object additional functions. Let’s say that you want to create an object named “Vityata” with the age of 15. (These are the properties). Then you may ask the object to do the following functions – sayIntroduce, sayBye, sayHello with or without additional parameters. Like this:

This is the result from our code:




It is rather small, but you still can see it GitHub!

Tagged with: , ,