I have not failed. I've just found 10,000 ways that won't work.
- Thomas Alva Edison
News
Site News
Latest Comments
Affiliates
Proxies
Contribute!
Chat
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
17,151
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
·
Typeof Function
·
Array Example
·
ParseInt(): Strings to Numbers
·
Learning Variables
·
Simple Arithmetic Operators
·
Function for Exponents
"AllSyntax.com" Copyright © 2002-2021; All rights lefted, all lefts righted.
Privacy Policy