JavaScript: Functions

Incorporating OOP into JavaScript for reusable logic.

Though many programmers focus their OOP skills in C# while designing logic interfaces and classes, it’s just as important to do so when creating presentation-layer logic so that the code may be easily reusable.
Below are examples of functions in JavaScript.

This illustrates two objects being created using constructor functions, literal syntax, added the values from the two objects to the third object, then writing the results

functions1

functions2

This illustrates assigning a function to another variable, then calling that variable.

functions3

This illustrates using a function as a class method.

functions4

functions5

This illustrates using several different objects’ methods that work in conjunction with each other — like overloading.

functions6 functions7

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 )

w

Connecting to %s