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

Untitled

By: a guest on Jun 13th, 2012  |  syntax: JavaScript  |  size: 0.59 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. var some_global_variable = 0;
  2.  
  3. var wat = function() {
  4.         some_global_variable = some_global_variable + 1;
  5.         console.log("lulz " + some_global_variable + " at " + this.someone_passed_it_in_I_guess);
  6. };
  7.  
  8. var SomeConstructor = function(some_name) {
  9.         this.someone_passed_it_in_I_guess = some_name;
  10.         this.lolFunction = function() {
  11.                 console.log(some_name);
  12.         };
  13. };
  14.  
  15. SomeConstructor.prototype.huh = wat;
  16.  
  17. var object_one = new SomeConstructor("roflcopter");
  18. var object_two = new SomeConstructor("butts");
  19.  
  20. object_one.lolFunction();
  21. object_two.lolFunction();
  22. object_one.huh();
  23. object_two.huh();