Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I find where a variable is defined at runtime?
    primarykey
    data
    text
    <p>I've been using jQuery and YUI side-by-side with no issues until recently. Occasionally, inside of a callback for, say, a YUI button, <code>$</code> will be shadowed by some other function (click for big version): <a href="https://i.stack.imgur.com/o0y4B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o0y4B.png" alt="console"></a></p> <p>and for the life of me, <em>I cannot figure out why this is happening</em>. Yes, I know I could be safe and use <code>jQuery</code> or <code>window.$</code> everywhere instead of just <code>$</code>, but that's just a workaround and not an actual fix.</p> <p>At runtime, how can I find where this <code>$</code> impostor is coming from? - e.g. find where it's declared, and why it's in my bleedin' scope.</p> <hr> <p>It turns out that this behavior is easily reproduced (at least in Chrome and Firefox 4) right here on Stack Overflow, since SO uses jQuery (again, click for full size):</p> <p><a href="https://i.stack.imgur.com/DSwZ3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DSwZ3.png" alt="more console"></a> <a href="https://stack.i.imgur.com/9c4aL.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/9c4aL.png" alt="still more console"></a></p> <p>I can only infer that <code>$</code> as </p> <pre><code>function () { return document.getElementById.apply(document, arguments) } </code></pre> <p>must be from the console itself!</p> <h2>Found it.</h2> <p><code>with</code> strikes again.</p> <p><img src="https://i.stack.imgur.com/Yd3DU.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/IThcT.png" alt="enter image description here"></p> <p>Chromium bug for this: <a href="http://code.google.com/p/chromium/issues/detail?id=70969" rel="nofollow noreferrer">http://code.google.com/p/chromium/issues/detail?id=70969</a></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.
 

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