September 2010
2 posts
2 tags
Asynchronous messaging
JavaScript runs in a single thread inside browsers. When the thread is busy, asynchronous events like user actions or XHR responses get queued up and only get processed when the currently running JavaScript execution thread becomes idle. Suppose you want to fire off an event but don’t want the code for handling that event to be run immediately: if (!this.fmt.test(this.value)) { ...
Sep 18th
2 tags
Know when it is no longer JSON
Do you ever call your variables that get populated from a JSON string something with “json” in them? function processData(json) { // if (json.accountType == "savings") ... } Realize that “JSON” only describes the format of the data you’re fetching through XHR or <script>. It is a string representation of an object. When you’re in the JavaScript...
Sep 8th