Is hoisting doing this:
var addEvent = window.addEventListener ? function ( e, s, f ) {
e.addEventListener( s, f );
} : function ( e, s, f ) {
e.attachEvent( 'on' + n, f );
};
?
No, this is feature detection.
Hoisting is the reason why this works:
foo(); // using a function before it is defined works because of hoisting
function foo() {}
because internally the browser handles this as
function foo() {}
foo();
The process of putting functions first no matter where they are defined is
called hoisting. So hoisting is nothing you do, but something the browser
does.
To avoid the confusion, Crockford recommends putting functions first in
you script.
Matt
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]