Local & Global Variable in Javascript (2)


/ Published in: JavaScript
Save to your folder(s)

يمكنني حذف السطر الثالث دون حدوث أي مشاكل


Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2.  
  3. var MyVariable; // Delete this line
  4.  
  5. function x()
  6. {
  7. MyVariable = 'Hello, World!';
  8. }
  9.  
  10. function y()
  11. {
  12. alert(MyVariable);
  13. }
  14.  
  15.  
  16. x();
  17. y();
  18. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.