JavaScript
  Home arrow JavaScript arrow Object-Oriented JavaScript: Using the `Pro...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Object-Oriented JavaScript: Using the `Prototype` Property
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 11
    2005-12-05

    Table of Contents:
  • Object-Oriented JavaScript: Using the `Prototype` Property
  • Prototyping objects: looking at the “prototype” property
  • Object interaction in JavaScript: applying Inheritance through the “prototype” property
  • Traversing object properties: using the “for in” loop structure

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Object-Oriented JavaScript: Using the `Prototype` Property


    (Page 1 of 4 )

    In this second part of this series, Alejandro Gervasio shows the correct implementation of the "Prototype" property, and how to use it to apply inheritance to many objects of the same family type.

    Introduction

    Here we are again. Welcome to the second part of the series “Object-oriented JavaScript.” As you know, this series goes through the implementation of user-defined objects in JavaScript, explaining the key points and introducing some advanced concepts. These concepts range from how to use Inheritance in multiple objects to developing real-world examples.

    In the first tutorial, I went over the basics of creating user-defined objects, and established the guidelines for understanding how static properties and methods can be assigned to them. In addition to setting up some hands-on examples, handy for illustrating the process for instantiating objects and utilizing their methods, I scratched the surface of some lesser-known topics, such as “Function” objects and the “constructor” property. Although these rather unusual aspects of object-oriented JavaScript certainly won’t cause a considerable impact on the way you develop your client-side applications, it’s worth having at least a basic grounding on how they can be used.

    Now, paying attention to this second part of the series, I’ll be showing, through easy-to-understand examples, the correct implementation of the “prototype” property, and its usefulness for applying Inheritance to many objects of the same family type. By the end of this article, you should have a better idea of how all these features fit together, and hopefully, you’ll be provided with the required knowledge for creating child objects, which will inherit some properties from base objects.

    Having drawn the general guidelines for this tutorial, it’s time to leap forward and learn more about user-defined objects in JavaScript. Let’s get started.

    More JavaScript Articles
    More By Alejandro Gervasio


       · This second tutorial explores the specific use of the "prototype" property, in order...
       · Great tutorial, it explains the prototype property very well!
       · Thank you for your positive commments on my article. I truly appreciate that and...
       · Its really a great article, but it does not explains the mechanics of constructors...
       · Thank you for commenting on my JavaScript article. With regard to your first...
       · After struggeling with many arcane explanations I found your example demonstrated...
       · Hi Stephen,Thank you for the kind comments on my JavaScript article, and I’m...
     

    JAVASCRIPT ARTICLES

    - Using the Style Object for Zebra Tables with...
    - Binary Searching
    - An Improved Approach to Building Zebra Tables
    - Assigning Background Colors Dynamically to Z...
    - Building Zebra Tables with CSS and JavaScript
    - JavaScript: Array Objects
    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...
    - Bulleted Menu of Links
    - Creating Click Loggers and Basic Markers wit...
    - Adding Pan Controls to Yahoo! Maps
    - Adding Zoom Controls to Yahoo! Maps
    - Working with Yahoo! Maps
    - Building Image Zooming Controls with the DOM...
    - Working with Multiple Graphics for a Zoom Ap...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway