How can using prototype be useful in javascript?

I regularly see people make make use of of antecedent in their Javascript formula though we nonetheless assimilate how it’s useful. Can someone here insist to me because we should make make use of of antecedent in my Javascript code?

One thought on “How can using prototype be useful in javascript?

  1. On the assumption that you don’t mean Prototype the javascript framework (frameworks save you time in implementing common functionality).

    prototype really helps when defining a class layout in javascript

    for example:

    I could have

    HelloPrinter = function(message) {
    ….this.message = message;
    };

    HelloPrinter.prototype.printHello = function() {
    alert("Hello " + this.message);
    };

    var x = new HelloPrinter("World");
    var y = new HelloPrinter("Earth");

    x.printHello();
    y.printHello();

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>