Tag Archives: OOPS

Object Oriented Programming in Javascript

Learned at Code Academy

1. Classes in Javascript:

Person is a class and bob and susan are instances of that class.

2. Inheritance:

 Here, Penguin class inherits Animal class and hence can access the function sayName().

3. Abstraction:

Public variables are those declared above (name, numLegs etc.)

Private variable is declared as shown below:

Here variable bankBalance is hidden and we need function getBalance() to show it.

Private methods can also be declared in same fashion by removing this keyword from then. You can use a private function by returning it from a public one.

* * * * *


Leave a comment

Filed under javascript