Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. Object.defineProperty(Array.prototype, 0, {
  2. get: function() {console.log("Got em"); window.someArray = this; return 0;},
  3. set: function() {console.log("Got em again")}
  4. });
  5.  
  6. (function() {
  7. let test = [];
  8. test[0];
  9. })();
  10.  
  11. (function() {
  12. let test = ["hello", "world"];
  13. test[0];
  14. })();
  15.  
  16. Object.defineProperty(Array.prototype, 'push', {
  17.  
  18. value: function(){
  19. // rest of the code as Array API give to push the array
  20. console.log("hello world ");
  21. }
  22. });
  23.  
  24. var arr = [];
  25. arr.push("Hi Jarvis");
  26.  
  27. Hello World
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement