Skip to content

JavaScript ​

JavaScript (JS) is a high-level, interpreted programming language originally designed for adding interactivity to web pages. Today, it is a multi-paradigm language used across web development, backend services, mobile apps, and even desktop applications.


1. Brief History of JavaScript ​

  • 1995 – Brendan Eich at Netscape created JavaScript in just 10 days, originally named Mocha, later renamed LiveScript, and finally JavaScript (partly for marketing, to ride on Java’s popularity).
  • 1996 – Microsoft introduced JScript (their implementation for IE 3).
  • 1997 – Standardized as ECMAScript (ES) by ECMA International (ECMA-262 spec).
  • 2009 – Node.js brought JS to the server.
  • 2015 onwards – ES6 (aka ES2015) revolutionized JS with modern features.

2. Major ECMAScript (ES) Version Updates ​

YearVersionKey Features
1997ES1First edition
1998ES2Minor changes
1999ES3Regular expressions, better error handling
2009ES5Strict mode, JSON support, Array.forEach, getters/setters
2015ES6 (ES2015)let, const, classes, modules, template literals, arrow functions, promises, default/rest/spread params
2016ES7Array.includes, exponentiation (**)
2017ES8async/await, Object.entries, Object.values
2018ES9Rest/spread in objects, async iterators
2019ES10Array.flat, Object.fromEntries, optional catch binding
2020ES11Optional chaining (?.), nullish coalescing (??), dynamic import()
2021+ES12+Logical assignment (`=, ??=), String.replaceAll, top-level await`, weak references, etc.

3. JavaScript Features with Examples ​

A. Basic Features ​

  1. Variables
js
var x = 5;   // function-scoped
let y = 10;  // block-scoped
const z = 15; // immutable
  1. Data Types
js
let num = 42;        // number
let str = "Hello";   // string
let bool = true;     // boolean
let obj = {a:1};     // object
let arr = [1,2,3];   // array
let n = null;        // null
let u;               // undefined
  1. Functions
js
function add(a, b) {
  return a + b;
}
console.log(add(2,3));
  1. Control Flow
js
for (let i=0; i<3; i++) console.log(i);

if (true) console.log("Yes");

B. Intermediate Features ​

  1. Arrow Functions
js
const multiply = (a, b) => a * b;
  1. Template Literals
js
let name = "Alice";
console.log(`Hello, ${name}!`);
  1. Destructuring
js
const [a,b] = [1,2];
const {x, y} = {x:10, y:20};
  1. Spread / Rest
js
let nums = [1,2,3];
let more = [...nums, 4,5];

function sum(...args) {
  return args.reduce((a,b)=>a+b, 0);
}
  1. Classes
js
class Person {
  constructor(name) { this.name = name; }
  greet() { console.log(`Hi, I'm ${this.name}`); }
}
  1. Modules (ES6)
js
// file: math.js
export const add = (a,b) => a+b;

// file: app.js
import { add } from './math.js';

C. Advanced Features ​

  1. Promises & Async/Await
js
function fetchData() {
  return new Promise(resolve => setTimeout(()=>resolve("Done"), 1000));
}

async function run() {
  let result = await fetchData();
  console.log(result);
}
run();
  1. Generators
js
function* numbers() {
  yield 1;
  yield 2;
  yield 3;
}
for (let n of numbers()) console.log(n);
  1. Optional Chaining
js
let user = {profile: {name: "Alice"}};
console.log(user.profile?.name); // Alice
console.log(user.settings?.theme); // undefined
  1. Nullish Coalescing
js
let x = null ?? "default"; // "default"
  1. Proxies
js
let obj = {a:1};
let proxy = new Proxy(obj, {
  get: (target, prop) => prop in target ? target[prop] : "Not found"
});
console.log(proxy.a, proxy.b);
  1. Symbols & Iterators
js
const sym = Symbol("id");
let obj2 = {[sym]: 123};
console.log(obj2[sym]);

4. Flavours of JavaScript Implementations ​

JavaScript isn’t just one runtime—it has multiple implementations:

ImplementationEnvironmentHighlights
Browser JSRuns inside browsers (V8 in Chrome, SpiderMonkey in Firefox, JavaScriptCore in Safari)DOM manipulation, events, APIs
Node.jsServer-side runtime (uses V8)File system, networking, backend services
DenoSecure JS/TS runtime by Node’s creatorBuilt-in TypeScript, secure by default, ES modules
BunNew runtime (powered by Zig & JavaScriptCore)Very fast, built-in bundler, test runner
Nashorn/GraalJSJava-based implementationsRunning JS on JVM
Adobe’s ExtendScriptAdobe apps scriptingAutomates Photoshop/Illustrator

Summary:

  • JS started in 1995, standardized as ECMAScript.
  • ES6 (2015) was the biggest leap with modern syntax.
  • Features range from basics (variables, functions) → intermediate (classes, modules) → advanced (async/await, proxies, generators).
  • Multiple runtimes exist: browsers, Node.js, Deno, Bun, etc.

Powered by VitePress