zimki | all bloggers | admin login | recent entries for James Duncan
 
JavaScript 1.7

James Duncan on Tue Oct 17 2006 14:46:33 GMT+0100 (GMT)

Mozilla have now released Firefox 2 RC 3, and with it comes JavaScript 1.7. You've been able to use the 1.7 features of JavaScript in Zimki for some time now, but the Firefox release provides a nice moment for me to talk about them here. For example generators and iterators, block scoping and my personal favorite, destructuring assignment.

Destructuring assignment is a thing of great beauty. Basically it means that the elements are decomposed in the logical pairs when assigning values to variables:

  [a, b, c, d] = [1, 2, 3, 4]; 

Saving you from having to type:

  a = 1;
  b = 2;
  c = 3;
  d = 4;

Naturally it goes further, and lets you swap values in a fairly obvious way:

  [a,b] = [b,a];

Or assign multiple values from a function:

  function foo() {
    return [1, 2];
  }
  [a, b] = foo();

Probably also worthy of note is that the new features of JavaScript 1.6 are all available in Zimki too (like E4X & Array Extras, as well as for each…in.

JavaScript is a lovely language to write code in, and these features are only helping…

leave a comment

name
email
comment