JavaScript Overview

Historical overview in 10 minutes

Historical overview in 10 minutes

1995

First Browser War

Brendan Eich created in 10 days a working prototype of JavaScript for the Netscape Navigator Web browser. The original name was Mocha, after renamed LiveScript and finally - JavaScript

1997

JavaScript was standardized by ECMA-262 Standard under the name ECMAScript

1999 - 2005

The Dark Ages

The only sparks are the joint endeavors which led to ActionScript, used in Adobe Flash Player platform.

2000

Douglas Crockford introduced the JSON format

2005

The Renaissance

Jesse James Garrett coins the term Ajax in his seminal paper Ajax: A New Approach to Web Applications

А bloom of JS open source projects and communities started: Prototype, jQuery, MooTools and many others

2008

The JavaScript engine race starts

Initial release of Google's V8 (JavaScript engine). Used in many server-side JavaScript based projects

2009

Released with Firefox 3.5, the TraceMonkey JavaScript engine was the first JIT compiler.
ECMAScript 5 (ES5) standardized.
Transpilers (source-to-source compilers) bloom starts.

2009

initial release of Node.js

2010

AngularJS initial release.

2012

Microsoft's TypeScript released

2013

React.js initial release

2014

Vue.js initial release

2014

WebComponents Standard

2015

EcmaScript 6 released

2017

WebAssembly Web standard was introduced

Or briefly...

Let the creator of JavaScript speak about its history:

JavaScript standards: ES5, ES6,ES2018, ... ES.Next?

JavaScript standards: ES5, ES6,ES2018, ... ES.Next?

ECMAScript 5 (ES5), 2009 year

New Features:

Strict mode
Syntax: legal trailing commas; multiline string literals
Object data Accessors
New Functionality in the Standard Library
JSON support

ECMAScript 6 (ES6)/ ECMAScript 2015 (ES2015) year

New Features:
git.io/es6features
es6-features.org
After ES6, the convention is to name ECMAScript versions by their release year, i.e. ES2016, ES2017, ...

ES.Next

Refers to next versions of JavaScript
Proposals are published in tc39/proposals repo
Finished proposals can be checked here: tc39/finished-proposals

Compatibility

ECMAScript compatibility table

The difference between JavaScript and other OOP languages

The difference between JavaScript and other OOP languages

Compilation

JavaScript is developed as a scripting language, which does not need to be compiled.

Contemporary JavaScript engines has compilation and optimization phases, but the developer does not need to carry about that.

OOP

The concept of class:
JavaScript: no class concept. Just a class keyword which is a syntactic sugar.
Classical OOP: have the concept of class as pure generalization.
types of abstraction:
JavaScript: one type of abstraction: the objects
Classic OOP: two types of abstractions: classes and objects.
prototype-based vs. class-based inheritance:
JavaScript: an object inherits from object.
Classic OOP: a class inherits from classes

Type system

JavaScript has dynamically typed system.

				var a;
				a = 5;
				a = "Howdy"; // no problem!
				a = [1,2,3]; // no problem, again!
			

Run time environment

The natural runtime environments for JavaScript are:
Any modern browser.
Over nodejs for various OS (Linux, macOS, Solaris, FreeBSD, OpenBSD, Microsoft Windows, etc.)

The object oriented nature of JavaScript: "everything is an object"?

The object oriented nature of JavaScript: "everything is an object"?

Data types and structures

Primitive types:
Boolean
Null
Undefined
Number
String
Symbol (new in ECMAScript 6)
Objects (Reference Data types):
Objects
Function
Indexed collections: Arrays and typed Arrays
Keyed collections: Maps, Sets, WeakMaps, WeakSets

Primitive types

Primitive types are not objects!


			console.log(typeof null); // "object" - A BUG, see bellow!
			console.log(typeof true); // "boolean"
			console.log(typeof undefined); // "undefined"
			console.log(typeof 42); // "number"
			console.log(typeof 'howdy'); // "string"
			console.log(typeof Symbol()); // "symbol"
		

the 'typeof null' return "object" due to a bug in the first release in JavaScript 3

Primitives Boxing

The primitive types boolean, number, string and symbol have corresponding object types (wrappers): Boolean, Number, String and Symbol

Primitives do not have methods, but can borrow from their corresponding wrapper, when needed.

Primitives Boxing: Example


		console.log( 3.141592653589793.toFixed(4) );
		//3.1416

		console.log( 'ada byron'.length );
		//9

		console.log( true.toString() );
		//"true"
	

Primitives Immutability

Immutability: entities whose state is not allowed to change over time
Immutability is a core principle in functional programming
All primitive types in JavaScript are immutable!

			var ada = 'Ada';
			console.log(ada); // 'Ada'

			ada.surname = 'Byron';
			console.log(ada.surname); // undefined
		

Objects

A collection of properties
Property values can be values of any type, including other objects
Properties are identified using key values
A key value is either a String or a Symbol value.

Objects

Objects are mutable!


			var ada = {};
			console.log(ada); //Object {}

			ada.surname = 'Byron';
			console.log(ada.surname); //Byron
		

Functions

Functions are objects that have an internal [[Call]] property
So, functions are mutable too!

			function foo(){}

			foo.id = 1
			console.log(foo.id); // 1
		

Indexed collections: Arrays and typed Arrays

Reference: Array Object @mdn
Reference: TypedArray Object @mdn

Example

Arrays are objects

			let arr = ['a','b','c'];
			arr.id = 1;

			console.log(`arr.id: ${arr.id}`);
			// arr.id: 1
		

Keyed collections: Maps

Maps - the Map object holds key-value pairs and remembers the original insertion order of the keys.

			let fruits = new Map();
			fruits.set('banana', 1);
			fruits.set('orange', 2);
			fruits.set('meat', 4);

			console.dir(fruits);
			// Map { 'banana' => 1, 'orange' => 2, 'meat' => 4 }
		

Keyed collections: Sets

Set - the Set object is a collections of unique values.

			let arr = ['a','b','c', 'b','a','b','c'];
			console.dir(arr);

			let uniqueValuesSet = new Set(arr);
			console.dir(uniqueValuesSet);

			//Set { 'a', 'b', 'c' }
		

Keyed collections: WeakMaps, WeakSets

Reference: WeakMap Object @mdn
Reference: WeakSet Object @mdn

These slides are based on

customised version of

Hakimel's reveal.js

framework