-1

What is the use of prototype in the following example..

FlyingFlowers.Calendar.prototype = {    
    init: function( selector, context ) {
        // Make sure that a selection was provided
        selector = selector || document;
        ..........
    },
};
Jonathan Lonowski
  • 121,453
  • 34
  • 200
  • 199
Niveditha
  • 107
  • 1
  • 7

1 Answers1

0

The JavaScript library named Prototype takes its name from the JavaScript prototype. In JavaScript, the prototype is the mechanism which provides inheritance (as opposed to, say, classes).

It's used to add properties or methods to an already defined object (somewhat like extending). For example:

function myNewObject(){
}

myNewObject.prototype.myCustomAttr = "Hello";

instance = new myNewObject();

alert(instance.myCustomAttr); // alerts Hello
Sridhar R
  • 20,190
  • 6
  • 38
  • 35