code_junkie

Why is my JavaScript function sometimes “not defined”?

Nov 11th, 2011
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. function copyArray( pa ) {
  2. var la = [];
  3. for (var i=0; i < pa.length; i++)
  4. la.push( pa[i] );
  5. return la;
  6. }
  7.  
  8. Function.prototype.bind = function( po ) {
  9. var __method = this;
  10. var __args = [];
  11.  
  12. // Sometimes errors -- in practice I inline the function as a workaround.
  13. __args = copyArray( arguments );
  14.  
  15. return function() {
  16. /* bind logic omitted for brevity */
  17. }
  18. }
  19.  
  20. <SCRIPT src="mycode.js"/>
  21.  
  22. <SCRIPT src="mycode.js"></SCRIPT>
  23.  
  24. __args = Array.prototype.slice.call(arguments);
  25.  
  26. (function() {
  27. function copyArray(pa) {
  28. // Details
  29. }
  30.  
  31. Function.prototype.bind = function ( po ) {
  32. __args = copyArray( arguments );
  33. }
  34. })();
Add Comment
Please, Sign In to add comment