SuperMonkey

cadeau

Aug 20th, 2012
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //variable non globale (à cause du "var" devant)
  2. var a = 666;
  3. function disp() {
  4.     alert(a); //a est undefined
  5. }
  6. disp();
  7.  
  8. //variable globale
  9. b = 555;
  10. function dispB() {
  11.     alert(b); //affiche 555
  12. }
  13. dispB();
  14.  
  15. //et aussi inversement
  16.  
  17. function doNothing() {
  18.     c = 12345;
  19. }
  20. doNothing();
  21. alert(c); // affiche 12345
  22.  
  23. function doNothingX() {
  24.     var d = 12345;
  25. }
  26. doNothingX();
  27. alert(d); // undefined
Advertisement
Add Comment
Please, Sign In to add comment