Skip to content

Instantly share code, notes, and snippets.

@tobie
Created February 28, 2011 12:11
Show Gist options
  • Save tobie/847241 to your computer and use it in GitHub Desktop.
Save tobie/847241 to your computer and use it in GitHub Desktop.
errors in callbacks
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>untitled</title>
<script type="text/javascript" charset="utf-8">
alReady = function( n, t, ready ) {
ready = function(){ for ( t = 0; ready && t < n; ) ready[ t++ ](); ready = 0 }
document.addEventListener && document.addEventListener( "DOMContentLoaded", ready, false )
!function check() {
ready && setTimeout( /^u|g$/.test( document.readyState ) ? check : ready, t *= 2 )
}()
return function( fn ){ ready ? ready[ n++ ] = fn : fn() }
}( 0, 1 );
alReady(function() {
console.log('one');
});
alReady(function() {
(0)(); // throws
});
alReady(function() {
console.log('three');
});
</script>
</head>
<body>
</body>
</html>
temp.html:19 one
temp.html:22 TypeError: Result of expression '(0)' [0] is not a function.
temp.html:19 one
temp.html:22 TypeError: Result of expression '(0)' [0] is not a function.
temp.html:19 one
temp.html:19 three
temp.html:22 TypeError: Result of expression '(0)' [0] is not a function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment