|
|
|
Common JavaScript Gotchas
(jblotus.com)
|
|
125 points
by jblotus
4908 days ago
|
|
PHP was my first programming language, and my initial exposure to JavaScript was through libraries like jQuery. There were things about JavaScript that always seemed to trip me up in the beginning due to how they worked differently than PHP. Heck there are still some things today that are confusing. I want to share some of the things that I struggled when I started working with JavaScript. I am going to cover the global namespace, this, knowing the difference between ECMAScript 3 and ECMAScript 5, asynchronous operations, prototypes, and simple JavaScript inheritance. |
|
This can manifest itself in many ways. Usually in the form of a UI element being displayed more than once, but often more subtly such as a HTTP request being sent more than once. Often the bugs only manifest themselves after a certain sequence of actions, for example: click this UI element, check this radio box, then hit submit and watch the net tab.
It's so often the root cause of Javascript bugs that if I or somebody else on my team has a Javascript problem, I often start by asking myself if it looks like it could be this. Lately I have begun to wonder if there isn't some slight truth to that inflammatory "Callbacks are the new goto" story that was on here a couple of months ago [1].
[1] http://elm-lang.org/learn/Escape-from-Callback-Hell.elm