After downloading the Firefox 2.0 beta, I found that It has JavaScript 1.7 engine. I never update my JS skills, so when I found out about several new feature of JS, it amazed me. It seems that JS 1.7 language design becoming more influenced with Ruby and Python. Remember to enable JS 1.7 parser in your HTML script use:

<script type="application/javascript;version=1.7"> Tags


function range(begin, end) {
  for (let i = begin; i < end; ++i) {
  yield i;

for (i in range(0, 10))
  document.write( i );

// or you can use these below
var r = range( 0, 10 );
  document.write( );

Both Will Output:


yield is a generator-iterator, so the range function produce an iterator. and whenever the next() method is called, yield got executed. Kinda influenced by the Ruby design.

Array Comprehensions

You can called array initialization shortcut. A one-liner favorite. Example:

var ten_squares = [i * i for (i in range(0, 10))];
document.write( ten_squares );

output: 0,1,4,9,16,25,36,49,64,81

ten_squares will be an array contains of square 0 to square 9. This is python influenced. Another python influenced designs are:


a = 10; b = 20;
[a, b] = [b, a];

function f() { return [1, 2]; }
[c, d] = f();

function f2() { return [1, 2, 4]; }
[x, , z] = f2();

I’m tired, I will continue this next time, holidays waiting :p