File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes JavaScript Prototype Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JavaScript Prototype" Watch "JavaScript Prototype" New topic
Author

JavaScript Prototype

Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Eric Pascarello:

Ko Ko Naing,

Using prototype in JavaScript is rather handy. It allows you to create your own methods. I think it is a lot cleaner to code like that. You can develop an oo with JavaScript by using prototypes and classes. Not to advertise, but if you were to pick up Ajax in action, we first develop the code in a straight foward linear approach, then we go back and refactor the code for an oo approach. Makes it so much easier to reuse code on every page. A lot of novices to JavaScript does not know this exists.

You can read about prototype here if you are interested: http://www.webreference.com/js/column34/index.html

A group of use on another forum started to build a large list of prototype functions. I think we are at 70+. My screen name there is A1ien51. http://webdeveloper.com/forum/showthread.php?t=61883

I have a few scripts there to convert times, calc business days, and much more.

If you want to continue talking about prototypes of oo JavaScript, start a new thread.

Eric

So it means that we can do OO JavaScript coding in AJAX. Is it one of the reasons that AJAX was invented for?

You mentioned that re-using existing scripts is very easy when we use prototypes of JavaScript. What is the difference between re-using functions and stuff from tradational JS files and re-using them with prototypes? Since I am more familiar with the traditional way, is there any reason why I have to deal with learning curve on studying prototypes? If there is a big advantage to do that, I will defintely go for that.

Could you please give some ideas for me about this? Thanks a lot...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Ko Ko Naing,

I will make a small write up later on today showing an example how a prototype makes the code seem to flow nicer compared to using regular functions. My boss is screaming right now so I need to try to get a bug fixed!

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaScript Prototype