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 ArticleInheritance 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 ArticleExtension 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 ArticleAttaching 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 ArticleExample 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 ArticleExample 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 ArticleExample 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 ArticleIllustrate 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 ArticleCreate 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 ArticleCreate 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