Constructor | function myObject() {
this.iAm = 'an object';
this.whatAmI = function() {
alert('I am ' + this.iAm);
};
};
myObject.prototype.run = function(){
this.whatAmI();
};
myObject.run();
| ready |
Literal | var myObject = {
iAm: 'an object',
whatAmI: function() {
alert('I am ' + this.iAm);
}
}
myObject.run = function(){
this.whatAmI();
};
myObject.run();
| ready |
Class | myObject = function() {
this.iAm = 'an object';
this.whatAmI = function() {
alert('I am ' + this.iAm);
};
};
myObject.prototype.run = function(){
this.whatAmI();
};
myObject.run();
| ready |
Class prototype | myObject = function() {
};
myObject.prototype.iAm = 'an object';
myObject.prototype.whatAmI = function() {
alert('I am ' + this.iAm);
};
myObject.prototype.run = function(){
this.whatAmI();
};
myObject.run();
| ready |
Class prototype ref | var iAm = 'an object';
var whatAmI = function() {
alert('I am ' + this.iAm);
};
myObject = function() {
};
myObject.prototype.iAm = iAm;
myObject.prototype.whatAmI = whatAmI;
myObject.prototype.run = function(){
this.whatAmI();
};
myObject.run();
| ready |
Class ref | whatAmI = function() {
alert('I am ' + this.iAm);
};
myObject = function(whatAmI) {
this.iAm = 'an object';
this.whatAmI = whatAmI;
};
myObject.prototype.run = function(){
this.whatAmI();
};
myObject.run();
| ready |
Constructor prototype | function myObject() {
};
myObject.prototype.iAm = 'an object';
myObject.prototype.whatAmI = function() {
alert('I am ' + this.iAm);
};
myObject.prototype.run = function(){
this.whatAmI();
};
myObject.run();
| ready |