A Brief History of JavaScript
Site: | Saylor Academy |
Course: | PRDV401: Introduction to JavaScript I |
Book: | A Brief History of JavaScript |
Printed by: | Guest user |
Date: | Monday, 28 April 2025, 7:29 PM |
Description
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.
Programming the browser
Java
- 1990: Java was developed at Sun Microsystems to replace C++
- 1994: The "Oak" programming language, originally developed for set-top boxes, is retargeted to the web for "applets"
- Java takes off and is the first memory safe language in widespread use
- Java takes off and is the first memory safe language in widespread use
JavaScript
- 1995: Brendan Eich develops the "Mocha" programming language at Netscape; Mocha is renamed "LiveScript" and then "JavaScript"
- JavaScript takes off and is included in the Microsoft's IE browser
- 1996: JavaScript is submitted to ECMA as a standard
Today
- Java still dominates server-side while JS dominates client-side and is also making inroads into server-side (eg, node.js)
Source: Daniel Jackson, https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-170-software-studio-spring-2013/lecture-notes/MIT6_170S13_32-java-intro.pdf This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License.
On JavaScript, from its inventor
JS had to "look like Java" only less so, be Java's dumb kid brother or boy-hostage sidekick. Plus, I had to be done in ten days or something worse than JS would have happened.
- Brendan Eich on Javascript
The Good Parts
In Javascript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders. The best nature of Javascript is so effectively hidden that for many years the prevailing opinion of Javascript was that it was an unsightly, incompetent toy. My intention here is to expose the goodness in Javascript, an outstanding dynamic programming language...
Deep down, Javascript has more in common with Lisp and Scheme than with Java. It is Lisp in C's clothing.
- Douglas Crockford in Javascript: The Good Parts
Syntax and Basic Types
SYNTAX
statements like Java
• while, for, if, switch, try/catch, return, break, throw
comments
• use //, avoid /**/
semicolons
• inserted if omitted (yikes!)
declarations
• function scoping with var
functions
• are expressions; closures (yippee!)
var MAX = 10; var line = function (i, x) { var l = i + " times " + x + " is " + (i * x); return l; } var table = function (x) { for (var i = 1; i <= MAX; i += 1) { console.log(line(i, x)); } } // display times table for 3 table(3);
1 times 3 is 3
2 times 3 is 6
3 times 3 is 9
4 times 3 is 12
5 times 3 is 15
6 times 3 is 18
7 times 3 is 21
8 times 3 is 24
9 times 3 is 27
10 times 3 is 30
< undefined
>
BASIC TYPES
primitive types
• strings, numbers, booleans
•
operators autoconvert
> 1 + 2 3 > 1 + '2' "12" > 1 * 2 2 > 1 * '2' 2
arrays
• can grow, and have holes
funny values
• undefined: lookup non-existent thing
• null: special return value
> a = [] [] > a[2] = 'hello' "hello" > a.length 3 > a[1] undefined > a[2] "hello" > a[3] undefined
equality
• use ===, !==
> 1 === 1 true > 1.0 === 1 true >'hello' === 'hello' true > [] === [] false
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