Don't like ads? PRO users don't see any ads ;-)
Guest

Bad Code Writing: Mixing Global and Local Variables

By: a guest on Jun 22nd, 2012  |  syntax: JavaScript  |  size: 0.18 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Global greeting variable.
  2. var greeting = "Ahoy";
  3.  
  4. var greet = function () {
  5.   // Local greeting variable.
  6.   var greeting = "Hello";
  7.   console.log(greeting);
  8. };
  9.  
  10. greet();