I have noticed that when coding in javascript, it doesn't matter if i declare the function before or after i call it. In other languages it will cause an exception, but when running javascript in chrome it works just fine. Is that only in chrome, or is that normal?
1 Answer
What you're seeing is function hoisting in action: http://elegantcode.com/2011/03/24/basic-javascript-part-12-function-hoisting
1 Comment
SeinopSys
Basically, setting it as a variable makes the function only work after the variable is set, and declaring it with the function keyword directly makes it accessible from anywhere, anytime.