The first lines of code of the jQuery source (bit.ly/jqsource) are:
(function( window, undefined ) {
// Use the correct document accordingly with window argument (sandbox)
var document = window.document,
I think I understand what the code does, but not why it does it. What is the “sandbox” all about?
It helps prevent people from overriding the main
window.documentordocument.Things like this:
If jQuery called
document.getElementById, it would fail miserably.As for
undefined, its a “hack” to get at the real value ofundefinedbecause one can do this:then conditions like this would fail.