Object Oriented JavaScript: Demo Calculator

Click here to create a new calculator | Remove the last calculator

This is 7:25pm, and I thought to make a summary of today. This morning, I was trying to convince an industrial attaché in my Company that she could get to love programming, but how? The simplest way to go is to show her that all that matters is your imagination and not the programming language itself. To avoid complexities, I thought I should let her understand me through JavaScript. But by the time we’re done we have a Calculator Object, and we can create as many as possible object of it and run them on the same page.

It is wonderful what JavaScript can do, and I think I should describe it as the strength of a creative web programmer. To get the best of the programming language, the first task is to avoid “cutting and pasting” junks of scripts that you don’t even understand on to your page. Get to understand the language and start writing your own. Second, is to stop looking at the language as a “less than” a programming language. As far as I know, you could have a complete object oriented program with JS. You could have your getters and setters for private method, inheritance, encapsulation et al. JS is not a classical object oriented language but prototypal.

On a calculator template, the start button creates new Calculator object and assign it to the template. You could have as many as possible templates that run separate Calculator objects independently.

Thank you.

Download Scripts