Quantcast
Channel: w3mentor » Object oriented Javascript
Browsing all 10 articles
Browse latest View live

A simple class in Javascript

<script language="JavaScript" type="text/JavaScript"> function UniversalClass() { window.alert("Welcome to my class!"); } var uc = new UniversalClass(); </script>Continue reading...

View Article


Inheritance with prototype in Javascript

function UniversalTranslator() { this.copyright = "(C) 2010 JavaScript Examples"; } function UniversalCounter() { this.Count = count; var numbers = { "en": "one, two, three", "fr": "un, deux, trois",...

View Article


Extension of the Date class in Javascript

The prototype property can also be used to extend JavaScript classes. In the following code, ISLEAPYEAR function () is implemented. It determines if the return value of getFullYear () is a leap year....

View Article

Attaching an event in Javascript

All major browsers support the method addEventListener (), which is part of the W3C model. The following example shows how to attach an event a button so that it works in all browsers: <script...

View Article

Example to illustrate Inheritance using JavaScript

In the example we define a base object called Car, and Create sub object called ferrari that inherits attributes from Car. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">...

View Article


Example to illustrate Polymorphism using JavaScript

To illustrate Polymorphism using JavaScript we define a base object called Automobile with attributes and behaviors. Then we create sub object called Mercedes and Porshce to share the Automobiles...

View Article

Example of Encapsulation using JavaScript

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>JavaScript - Encapsulation Exercise</title> </head>   <body> <p>...

View Article

Illustrate how to manipulate JavaScript variables for web pages

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>JavaScript - Creating JavaScript variables for web pages 1</title> </head>...

View Article


Create a Monthly Auto Loan Payment Calculator in Javascript

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>JavaScript - Loan Calculator</title> </head>   <script...

View Article


Create and display custom objects using JavaScript

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>JavaScript - Create and Display Object Types</title> </head> <script...

View Article
Browsing all 10 articles
Browse latest View live