bhylu.com

Advertisements

JS 2009 (ES5)

The 2009 edition added strict mode, JSON support, and array helpers such as map. You may meet this style while maintaining older code.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

"use strict";
var prices = [3, 5];
console.log(prices.map(function (price) { return price * 2; }));

What happens

The older function syntax still produces [6,10].