Wise men speak because they have something to say; Fools because they have to say something.
- Plato (427-347 B.C.)
News
Site News
Latest Comments
Affiliates
Proxies
Contribute!
Tutorials
Newest Articles
Most Popular
Highest Rated
Latest Comments
Code Samples
Newest Code
Most Popular
Highest Rated
Latest Comments
Blogs
Admins Blog
Newest Blogs
Most Popular
Highest Rated
Latest Comments
Forums
Latest Posts
Latest Topics
Memberlist
[login]
|
[Register]
Object Orientation
by: javajunkie314
Description:
Creates a JavaScript Class using prototypes.
Code:
// Circle is a function that creates a new Object function Circle(r) { // Set the property radius this.radius = r; }; // area is now a method of Circle that returns the area // of the Circle object Circle.prototype.area = function() { return this.radius * Math.PI; }; var myCirc = new Circle(4); // new Circle with radius of 4 document.writeln(myCirc.area()); // Writes 12.5663...
No Comments for this page.
You Must be
signed in
or a
member
to comment.
Code Stats
6,623
Views
0
Total Comments
5
Rating of 5 (
Votes)
Code Options
·
Login to Rate This Code
·
Login to Post a Comment
·
Read more by this author
Related
·
Learning Variables
·
ParseInt(): Strings to Numbers
·
Functions for text properties
·
bgColor and fgColor
·
window.prompt
·
Array Example
"AllSyntax.com" Copyright © 2002-2010; All rights lefted, all lefts righted.
Privacy Policy
|
Internet Rank
Credit Counseling
-
Credit Consolidation
-
Credit Card Consolidation
-
United Specialties