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

Untitled

By: a guest on May 15th, 2012  |  syntax: None  |  size: 0.51 KB  |  hits: 18  |  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. Javascript overriding/adding methods to the prototype
  2. Date.prototype.now= function (){
  3.     return 23;
  4. }
  5.  
  6. $('#foo').append(Date.now());
  7.        
  8. Array.prototype.indexOf = function(){
  9.     return 23;
  10. }
  11. var bar = Array();
  12. bar[0] = "a";
  13. $('#bar').append(bar.indexOf("a"));
  14.        
  15. Date.prototype.now = function () {
  16.     return 23;
  17. }
  18.        
  19. Array.prototype.indexOf = function(){
  20.     return 23;
  21. };
  22.        
  23. var bar = [];
  24. bar.indexOf('a');
  25.        
  26. Date.prototype.now = function() {
  27.   return 23;
  28. }
  29. Date = new Date();
  30. document.write(Date.now());