A Brief History of JavaScript

JavaScript (which began as Netscape's Mocha) was created in 1995 by Brendan Eich to allow HTML developers to write scripts in their webpages. Read this article to learn about features and functionality that supported the early development of the language. These included a Java-like syntax, basic data types, and objects with classes.

Objects

literals
› o = {prop: val, ...}

properties
› get: x = o.p
› set, add: o.p = e
› delete: delete o.p

prototypes
› lookup along chain

> point = {x: 1, y: 2}
Object
 1. x: 1
 2. y: 2
 3. __proto__: Object
> point.x
1
> point.z
undefined
> point.z = 3
3
> point.z
3
> delete point.z
true
> point.z
undefined

> var Point = function (x, y) {this.x = x; this.y = y;}
undefined
> Point.prototype.magnitude = function () {return
Math.sqrt(this.x * this.x + this.y * this.y);}
function () {return Math.sqrt(this.x * this.x + this.y *
this.y);}
> p = new Point(1,2)
Point
> p.x
1
> p.magnitude
function () {return Math.sqrt(this.x * this.x + this.y *
this.y);}
> p.magnitude()
2.23606797749979