Posts

Prototypal Inheritance - Object Oriented JavaScript

Image
It has always amazed me how JavaScript handles Inheritance via Prototypes . Well, if you search the net (and unluckily if you are new to JavaScript), in no time you will find yourself crushed beneath tons of cryptic explanations, and you will probably want to run away and never look back at Prototypal Inheritance ever. But trust me, it is actually easy and fun. In simple words , in JavaScript world every object has a property named “prototype” which holds the parent object of that object. Got it? No? Ok don’t worry, we are only 2 minutes away from our destination . Let see it in action... Practice JavaScript in Browser Console. Browser console is probably the only tool you will ever need throughout your JavaScript programming career to quickly run any JS code to debug/study or just to clear a concept. Open your favorite browser in your computer (

Classes and Objects - Object Oriented JavaScript

Image
... And then the skeptics went to the Ancient Coder and asked, "How can JavaScript be a great language? It doesn’t even support OOP" ... The Old One, sitting in his pose of meditation on top of Mt. Himalayas, smiled calmly and said to them, "Go, read Barick’s Blog ..." So, to obey the Old Meditator, I am writing this blog, to give you a glimpse of JavaScript’s OOP capabilities. We are talking about pre- ES6 world... So, no "Class" keyword... So, if you are from an OOP background, you probably know what a "Class" is. A "class" defines a category or rather a blueprint for a specific type of objects; a guideline that every object of that category must obey to be in that group. Class tells us about the structure of the object. Actually, anyone can create a class with that special keyword, cleverly named, "Class". But what's really interesting is how we can do it i