Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 JAVASCRIPT


  A String is not an Error

I decided to write a little article to discourage an unfortunately common pattern in Node.JS modules (and browser JavaScript, to a lesser extent) that can boil down to these two examples:// A:function myFunction () {  if (somethingWrong) {    throw 'This is my error'  }  return allGood;}and// B: async Node.JS-style callback with signature `fn(err, …)`function myFunction (callback) {  doSomethingAsync(function () {    // …    if (somethingWrong) {      callback('This is my error')    } else {    &nb...

3,421 0       JAVASCRIPT NODE.JS STRING ERROR OBJECT


  JavaScript as a First Language

At Khan Academy we've been investigating teaching Computer Science to students in some new and interesting ways. The most interesting aspect of which is that we're likely going to be teaching them JavaScript as their first language.We're in a very unique position as we're primarily aiming to teach students who've been through our previous math and science-centric curriculum. Because of this we can create some rather compelling exercises and projects that never would've been feasible otherwise.The prospect of teaching the JavaScript language as a first language is actually really exciting. Teac...

5,784 0       PROTOTYPE JAVASCRIPT LEARNING FIRST LANGUAGE INHERITENCE


  ECMAScript 6 looks promising

I am quite excited about ECMAScript 6, after watching David Herman’s talk at YUIConf 2011. I am especially looking forward to seeing some of these features landing up on V8 soon, so that I can use it on node.js. These additions will solve many common sources of frustration that newcomers face when working with JavaScript. Although the spec is not expected to be finalized till 2013 (so says David in the video), a lot of these features are expected to hit Chrome and Firefox much before that. I am personally looking forward to the following: let keyword The let keyword has a block scope. ...

1,523 0       JAVASCRIPT NEW FEATURE ECMASCRIPT 6 LET TEMPLATE


  Introducing JavaScript native file management

TL;DRThe Mozilla Platform keeps improving: JavaScript native file management is an undergoing work to provide a high-performance JavaScript-friendly API to manipulate the file system.The Mozilla Platform, JavaScript and FilesThe Mozilla Platform is the application development framework behind Firefox, Thunderbird, Instantbird, Camino, Songbird and a number of other applications.While the performance-critical components of the Mozilla Platform are developed in C/C++, an increasing number of components and add-ons are implemented in pure JavaScript. While JavaScript cannot hope to match the spee...

1,579 0       JAVASCRIPT FILE LOCAL FILE FIRFOX MOZILLA


  A turing machine in 133 bytes of javascript

Multiply turing machineThe fact it took me 20 lines of javascript to implement a nondeterministic turing machine simulatorlast week kept me up at night. All weekend. Too much code for something so simple and I kept having this gut feeling implementing a basic version shouldn’t take more than 140 bytes.Sunday afternoon I sat down for about an hour, collected my thoughts, and started pumping out code with cryptic variable names. It was beautiful, first version ...

3,069 0       JAVASCRIPT TURING MACHINE SIMPLE CODE


  The Ultimate GetElementsByClassName, Anno 2008

Two and a half years ago, I released the first version of getElementsByClassName. With how web browsers has evolved since, I thought I’d release a real ultimate version, dated 2008. Native Web Browser SupportSafari 3.1 has native getElmentsByClassName support, and upcoming Firefox 3 and Opera 9.5 will have it too. It only leaves out, you’ve guessed it, Internet Explorer.The Necessity Of This ScriptLiving in a world where Microsoft is halting every possible way the web could evolve, this means that you will need a custom script for this for years to come. Also,...

1,924 0       JAVASCRIPT IMPLEMENTATION GEELEMENTSBYCLASSNAME CROSS BROWSER COMPATIBLE


  Hash Tables in Javascript

IntroductionHash tables are a permutation of associative arrays (i.e. name => value pairs). If you use PHP, then you are very familiar with this type of data structure already since all PHP arrays are associative.The Javascript language implements very loose and somewhat limited support for associative arrays. Any JavaScript array can use other objects as keys, making it a hash, but there exists no formal constructor for initializing them and it is more or less unweildy to work with. A short example of a hash in JavaScript would be as follows:var myArray = new Array();myArray['one'] = 1;myA...

4,809 0       JAVASCRIPT ARRAY IMPLEMENTATION HASHTABLE


  UIWebView Secrets - Part1 - Memory Leaks on Xmlhttprequest

My first blog post on iphone subject reveal a big memory bug when using UIWebView component. This is the (only one) component to display some HTML content in an iphone interface. UIWebView object has a lot of differents issues and I’m going to highlight the biggest of them. Actually, all XMLHttpRequests used in javascript code are fully leaking!!! I mean when you do a request that retrieve 100ko of data, your memory used grow up for 100ko! This bug is not always active, but almost always. In fact the trigger to enable it is to simply open one link in your UIWebView. For example, clickin...

7,357 0       XMLHTTPREQUEST MEMORY LEAK MOBILE DEVICE UIWEBVIEW