Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>sounds like you're having a collision of global objects. your best bet in this scenario is to move all your code into a namespace, by which I mean create an object or anonymous function to house the javascript code you've written.</p> <p>for example instead of just doing </p> <pre><code>var myWord = 'hello!'; alert(myWord); </code></pre> <p>where the name <code>myWord</code> might already be in use, you could do </p> <pre><code>(function() { var myWord = 'hello!'; alert(myWord); })(); </code></pre> <p>or if you need things to persist,</p> <pre><code>var myUniqueNamespace = new (function() { this.myWord = 'hello!'; })(); alert(myUniqueNamespace.myWord); </code></pre> <p>where you only need to ensure that <code>myUniqueNamespace</code> is indeed a unique name, and you can add whatever names you like as properties to it.</p> <p>re closure comment: not quite, but we can make it one like this</p> <pre><code>var myUniqueNamespace = new (function() { var myWord = 'hello!'; this.sayWord = function() { return myWord; }; })(); alert(myUniqueNamespace.sayWord()); </code></pre> <p><code>myWord</code> exists within the scope of the anonymous function used to create <code>myUniqueNamespace</code>, so you can't get do it directly from the outside (similar to a private member in other languages). however the method <code>sayWord</code> is defined in the same scope as <code>myWord</code> and closes over it, meaning that access to <code>myWord</code> is maintained within the method defintion. that might not be the clearest explanation but I hope the example makes it clear.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload