Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 15th, 2012  |  syntax: JavaScript  |  size: 0.72 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function Foo(bar) {
  2.     this.thing = bar
  3. }
  4.  
  5. Foo.prototype.canRaep = function(other) {
  6.     return this.thing > other.thing;
  7. }
  8.  
  9. Foo.prototype.doRaep = function(other) {
  10.     if (this.canRaep(other))
  11.         return this.thing + ' raped ' + other.thing;
  12.     return this.thing + ' could not rap ' + other.thing;
  13. }
  14.  
  15. alfa = new Foo('the alpha')
  16. notalfa = new Foo('bayuh')
  17. clayton = new Foo('Clayton')
  18.  
  19. console.log(alfa.doRaep(notalfa))
  20. console.log(alfa.doRaep(clayton))
  21. console.log(notalfa.doRaep(clayton))
  22. console.log(clayton.doRaep(alfa))
  23. console.log(clayton.doRaep(notalfa))
  24.  
  25. ...
  26.  
  27. the alpha raped bayuh
  28. the alpha raped Clayton
  29. bayuh raped Clayton
  30. Clayton could not rap the alpha
  31. Clayton could not rap bayuh