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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s