I'm newbie in javascript.I ever read the article with the SAEF,while i still have question, the code is below:
var addEvent = (function( window, document ) {
if ( document.addEventListener ) {
return function ( elem, type, callback ) {
//if elem exist and is a single node.
if ( elem && !elem.length || elem === window ) {
elem.addEventListener( type, callback, false );
} else if ( elem && elem.length ) { //elem is an node of array
for ( var i = 0; i < elem.length; i++ ) {
addEvent( elem[i], type, callback );
}
}
}
} else if ( document.attachEvent ) {
return function ( elem, type, callback ) {
//if elem exist and is a single node
if ( elem && !elem.length || elem === window ) {
elem.attachEvent( 'on'+type,
function () {
callback.call( elem, window.event );
} );
} else if ( elem && elem.length ){
for ( var i = 0; i < elem.length; i++ ) {
addEvent( elem[i], type, callback );
}
}
}
}
})( this, document );
My question is what does the param this and document mean for?Are both of them the real param that will replace the param of window and document which are contained within the Anonymous function?