That's one of the weirdest thing I have ever encountered in JavaScript maybe some of you know the reason it behaves the way it does.
If you will run this code you will get undefined
var fn = function(div,speed){
}
(function(){console.log(fn)}())
BUT if we add a variable
var fn = function(div,speed){
}
var weird = true;
(function(){console.log(fn)}())
Now it will return the function
I don't understand what on earth is going on?
It can also work like that
var fn = function(div,speed){
}
!function(){console.log(fn)}()