
Untitled
By: a guest on
Jun 15th, 2012 | syntax:
JavaScript | size: 0.72 KB | hits: 23 | expires: Never
function Foo(bar) {
this.thing = bar
}
Foo.prototype.canRaep = function(other) {
return this.thing > other.thing;
}
Foo.prototype.doRaep = function(other) {
if (this.canRaep(other))
return this.thing + ' raped ' + other.thing;
return this.thing + ' could not rap ' + other.thing;
}
Foo.prototype.prepareRaep = function(other, cb) {
setTimeout(function(this_) { cb(this_.doRaep(other)) }, 10, this);
}
alfa = new Foo('the alpha')
notalfa = new Foo('bayuh')
clayton = new Foo('Clayton')
console.log(alfa.doRaep(notalfa))
console.log(alfa.doRaep(clayton))
console.log(notalfa.doRaep(clayton))
clayton.prepareRaep(alfa, console.log)
clayton.prepareRaep(notalfa, console.log)