JavaScript ABC – Syntax + Built-ins

1. Core Grammar / Syntax

Statements

StatementExample
ExpressionStatementa + b;
BlockStatement{ let x = 1; let y = 2; }
IfStatementif (x>0) { y=1; } else { y=2; }
SwitchStatementswitch(x){ case 1: y=1; break; default: y=0; }
ForStatementfor(let i=0;i<3;i++){ console.log(i); }
WhileStatementwhile(x<5){ x++; }
DoWhileStatementdo { x++; } while(x<5);
ThrowStatementthrow new Error("oops");
TryCatchFinallytry { risky(); } catch(e){ console.log(e); } finally { cleanup(); }

Declarations

DeclarationExample
VariableDeclarationlet x=0; const y=1; var z;
FunctionDeclarationfunction f(a){ return a+1; }
ClassDeclarationclass A { constructor(x){ this.x=x; } }

Expressions

ExpressionExample
AssignmentExpressiona = 5;
BinaryExpressiona + b
UnaryExpression!a, -b
LogicalExpressiona && b, a || b
ConditionalExpressiona ? b : c
CallExpressionf(3)
MemberExpressionobj.prop, arr[0]
ObjectExpression{ a:1, b:2 }
ArrayExpression[1,2,3]
FunctionExpressionconst f = function(){}
ArrowFunctionExpressionconst f = () => {}
TemplateLiteral`Hello ${name}`

2. Global Built-in Objects

Fundamental

ObjectExample
Objectconst o = {a:1};
Functionfunction f(){}
Booleanlet b = true;
Symbolconst s = Symbol('id');
Errorthrow new Error('oops');
BigInt12345678901234567890n;

Numbers & Dates

ObjectExample
NumberNumber('123');
BigIntBigInt(123);
MathMath.max(1,5); Math.random();
Datenew Date();

Text

ObjectExample
String'abc'.toUpperCase();
RegExp/abc/.test('abc');
TemplateLiteral`Value: ${x}`

Indexed Collections

ObjectExample
Array[1,2,3].map(x=>x*2);
Typed Arraysnew Uint8Array([1,2,3]);

Keyed Collections

ObjectExample
Mapconst m = new Map(); m.set('a',1);
Setconst s = new Set([1,2]);
WeakMapconst wm = new WeakMap();
WeakSetconst ws = new WeakSet();

Structured Data

ObjectExample
JSONJSON.stringify({a:1}); JSON.parse('{"a":1}');
ArrayBuffer / DataViewnew ArrayBuffer(16); new DataView(buf);

Control Abstractions

ObjectExample
PromisePromise.resolve(5).then(console.log);
GeneratorFunction / Generatorfunction* g(){ yield 1; }
AsyncFunctionasync function f(){ await fetch('/'); }

Reflection & Metadata

ObjectExample
Proxyconst p = new Proxy({}, {});
ReflectReflect.get(obj,'prop');

Internationalization

ObjectExample
Intl.Collatornew Intl.Collator('en').compare('a','b');
Intl.NumberFormatnew Intl.NumberFormat('en-US').format(12345);
Intl.DateTimeFormatnew Intl.DateTimeFormat('en').format(new Date());

Others

ObjectExample
consoleconsole.log('hello');
globalThisglobalThis.x = 1;
evaleval('2+2');
parseInt / parseFloatparseInt('42'); parseFloat('3.14');