• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaScript Prototype

 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic