@mrhooJun 23.2011 — #[CODE]There are no classes in javascript. There are objects with constructor functions.
function Bumbershoot(arg){ for(var p in arg){ this[p]= arg[p]; } this.report= function(what){ return this[what] || what+' is not here'; } } /* You can't call a method without an instance if it is defined in the constructor
alert(Bumbershoot.report('Mimsey'));
returns >>> ERROR-Bumbershoot.report is not a function
You can call a prototype method without an instance, but its this is an 'empty' instance of the constructor
Bumbershoot.prototype.report2= function(what){ return this[what] || what+' is not in here';
} alert(Bumbershoot.prototype.report2('Mimsey')) returns >>> 'Mimsey is not in here'
And if you have another object that could use the method you can call it without an instance:
var O={a:1,b:2,c:3,d:4,e:5}; alert(Bumbershoot.prototype.report2.call(O, 'c')) returns >>> 3 */[/CODE]