Jump to content


Avoid pollute the global namespace

  • Please log in to reply
No replies to this topic

#1 Laksekjønn

  • Members
  • 455 posts

Posted 12 July 2017 - 03:52 PM

At the default project options, when you left unchecked the option:
[ ] embedd JS into HTML file

it will generate in the main index.html this:
<script src="main.js"></script>
All javaScript declarations outside of a function are in the global scope. Defining things in the global namespace is to be avoided.
I'll use a differente pattern, a simple closure around the main.js generated code

(function() { /* the main.js code */})();

  • Nico Wouterse likes this

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users