Guest User

Untitled

a guest
May 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. // Google Closure Compiler examples
  2. // Malformed JS
  3. var foo = {
  4. attrib1: 'foo',
  5. attrib2: 'bar', // <--- trailing comma
  6. }
  7.  
  8. // RESULT:
  9. // [vincentc@local bad_js]$ gjs --js bad_js.js
  10. // bad_js.js:8: ERROR - Parse error. Internet Explorer has a non-standard intepretation of trailing commas. Arrays will have the wrong length and objects will not parse at all.
  11. // }
  12. //
  13. // 1 error(s), 0 warning(s)
  14.  
  15.  
  16. // Really wordy JS
  17. var bar = function () {
  18. // I am a really wordy js file
  19. // with many cool comments!
  20. console.log("I am a debug statement");
  21.  
  22. x = 10;
  23. if (true) {
  24. x = 1 + 1;
  25. new Ajax.Updater('', {
  26. // We like to make tons of comments
  27. onSuccess: function () {
  28. $('cool_div').hide();
  29. },
  30.  
  31. onComplete: function () {
  32. $('cool_div').show();
  33. }
  34. });
  35. }
  36.  
  37. }
  38.  
  39. // RESULT (notice: the if block has been removed since it always evals to true.
  40. // The '1+1' evaluation has just been replaced by 2):
  41. // [vincentc@local bad_js]$ gjs --js bad_js.js
  42. // var bar=function(){console.log("I am a debug statement");x=10;x=2;new Ajax.Updater("",{onSuccess:function(){$("cool_div").hide()},onComplete:function(){$("cool_div").show()}})};
Add Comment
Please, Sign In to add comment