JavaScript Tutorial

Object prototypes
Previous Home Next

javascript Prototypes allow you to easily define methods to all instances of a particular object. Prototyping also provides the facility to add, replace, or delete methods

Syntax : = value

Example :

function book(title, author){
    this.title = title;  = author;


   var myBook = new book("java", "prasun");
   book.prototype.price = null;
   myBook.price = 500;
   document.write("Book title is : " + myBook.title + "<br>");
   document.write("Book author is : " + + "<br>");
   document.write("Book price is : " + myBook.price + "<br>");

Output :

Book title is : java
Book author is : prasun
Book price is : 500
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Comment / Feedback: