What is difference between define function by prototype and class property?

Follow my code,
Apple is define function by prototype.
Banana is define function by class property.

var Apple = function(){}
Apple.prototype.say = function(){
    console.debug('HelloWorld');
}
var Banana = function(){
    this.say = function(){
        console.debug('HelloWorld');
    }
}

var a = new Apple();
var b = new Banana();

a.say();
b.say();

Are these difference ?

44
задан diewland 6 May 2011 в 13:58
поделиться