Wasted a couple of “What the hell is wrong here?” moments about this code:
1 2 3 4 5
doSomething() is not a function.
Obviously, I missed a semicolon after the
doSomething() call, but I didn’t imagine this caused the error.
JS usually forgives about missing semicolons, if next statement is not in the same line. However, having the parenthesis of the self executed function made JS parse code as
Which expects the returned value from
doSomething to be a function, that is executed with the anonymous function as a first argument.
So in conclusion, never forget semicolons. Ever. Even when just debugging code.