JavaScript ES5 (ECMAScript 2009)

ECMAScript 5 (ES5) was released in 2009 and brought several important features to JavaScript. It was widely adopted and is supported by all modern browsers.

Key Features

  1. Strict Mode: Introduced "use strict" to enforce stricter parsing and error handling.
  2. JSON Support: Added native JSON parsing with JSON.parse() and JSON.stringify().
  3. Array Methods: Introduced new array methods like forEach(), map(), filter(), reduce(), and some().
  4. Object Methods: Added Object.create(), Object.keys(), Object.defineProperty(), and others for better object manipulation.
  5. Function Binding: Introduced the bind() method for explicitly setting the this value in function calls.
  6. Property Attributes: Allowed defining property attributes like writable, enumerable, and configurable.

Example

"use strict";

// Using new array methods
let numbers = [1, 2, 3, 4, 5];
let doubled = numbers.map(num => num * 2);
console.log(doubled); // [2, 4, 6, 8, 10]

// Object manipulation
let person = Object.create(null);
Object.defineProperty(person, 'name', {
    value: 'John',
    writable: false,
    enumerable: true
});

console.log(person.name); // "John"
person.name = 'Jane'; // This won't change the name due to writable: false
console.log(person.name); // Still "John"

ES5 laid the foundation for modern JavaScript development and is still widely used today.