Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>var len = t.length &gt;&gt;&gt; 0; </code></pre> <p>This was covered pretty well in <a href="https://stackoverflow.com/questions/3081987/what-good-does-zero-fill-bit-shifting-by-0-do-a-0">this question</a> Basically it makes sure the number is a non-negative 32 bit int.</p> <p>As for the Object constructor:</p> <pre><code>var t = Object(this); </code></pre> <p>If <em>this</em> is null or undefined, it'll return an empty object. From the <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object" rel="nofollow noreferrer">MDC Docs on Object</a></p> <blockquote> <p>The Object constructor creates an object wrapper for the given value. If the value is null or undefined, it will create and return an empty object, otherwise, it will return an object of type that corresponds to the given value.</p> </blockquote> <p>They're both just quick ways to do error correction.</p> <p>EDIT: I was thinking way too hard about the thisp part. I was assuming that using the arguments array was a way to ensure arguments were defaulting to undefined, but they do that on their own anyway. Mike Hofer got it right in the comments. It's Mozilla's coding style to indicate optional parameters. Function.call defaults to global if null or undefined is passed in as the first argument. From the <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/call" rel="nofollow noreferrer">MDC Docs on Function.call</a> </p> <blockquote> <p>thisArg: Determines the value of <strong>this</strong> inside fun. If thisArg is null or undefined, <strong>this</strong> will be the global object. Otherwise, <strong>this</strong> will be equal to Object(thisArg) (which is thisArg if thisArg is already an object, or a String, Boolean, or Number if thisArg is a primitive value of the corresponding type). Therefore, it is always true that typeof <strong>this</strong> == "object" when the function executes.</p> </blockquote>
 

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