Hacker News new | ask | show | jobs
by EzGraphs 4862 days ago
There have been a lot of articles re-hashing Crockford's analysis floating around recently. These have been valuable, but they tend to focus on the same topics in the core language (largely concerned with scope, use of closures, behavior of basic data types, and functional programming). In web development, the DOM and events end up being a more common area where I and other devs are tripped up. A few things I wish I knew before a deep dive into an large scale JavaScript project:

1) Newly added elements will not respond unless events are bound to them. One solution (thinking in jQuery here) is to bind events higher up the DOM.

2) Each line in code may not simply execute in sequence. For example, asynchronous ajax calls require subsequent calls to be nested in callbacks.

1 comments

Regarding #2, I highly recommend reading Trevor Burnham's excellent book Async JavaScript. It goes into a great deal of detail explaining how async operations work, and ways of dealing with them.