Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>for</code> enumeration is going to go over <em>every</em> member of the object you passed it. In this case an array, which happens to have functions as members as well as the elements passed.</p> <p>You could re-write your for loop to check if <code>typeof stypes[t] == "function"</code> or yada yada. But IMO you are better off just modifying your looping to only elements.. </p> <pre><code>for(var i = 0, t; t = stypes[i]; ++i){ if (t != x) { alert(t); } } </code></pre> <p>Or </p> <pre><code>for(var i = 0; i &lt; stypes.length; ++i){ if (stypes[i] != x) { alert(stypes[i]); } } </code></pre> <p>I wanted to migrate my last comment up to the answer to add the notice of the a caveat for the first type of loop.</p> <p>from <a href="https://developer.mozilla.org/En/A_re-introduction_to_JavaScript" rel="noreferrer">Simon Willison's "A re-introduction to JavaScript"</a>..</p> <pre><code>for (var i = 0, item; item = a[i]; i++) { // Do something with item } </code></pre> <blockquote> <p>Here we are setting up two variables. The assignment in the middle part of the for loop is also tested for truthfulness - if it succeeds, the loop continues. Since i is incremented each time, items from the array will be assigned to item in sequential order. The loop stops when a "falsy" item is found (such as undefined).</p> <p>Note that this trick should only be used for arrays which you know do not contain "falsy" values (arrays of objects or DOM nodes for example). If you are iterating over numeric data that might include a 0 or string data that might include the empty string you should use the i, j idiom instead.</p> </blockquote>
    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.
    3. 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