r/javascript • • Feb 23 '13

Common JavaScript "Gotchas"

https://github.com/stevekwan/best-practices/blob/master/javascript/gotchas.md
16 Upvotes

50 comments sorted by

View all comments

0

u/[deleted] Feb 23 '13

[deleted]

4

u/[deleted] Feb 24 '13

To further elaborate:

var myFunction = function myFn(arg1, arg2) { 
    console.log(arg1, arg2);
};

myFunction('foo', 'bar'); // -> foo bar
myFn('foo', 'bar'); // Reference Error: myFn is not defined

To someone that didn't know better or just didn't scan the line properly this can be a frustrating gotcha to catch.