0% found this document useful (0 votes)
7 views2 pages

JavaScript Core Mental Model Complete Outline

The document outlines key JavaScript fundamentals including variable types, control flow, and functions. It covers scope, closures, objects, prototypes, arrays, higher-order functions, and asynchronous programming. Additionally, it highlights modern ES6+ features and advanced patterns for efficient coding practices.

Uploaded by

ZewduErkyhun
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

JavaScript Core Mental Model Complete Outline

The document outlines key JavaScript fundamentals including variable types, control flow, and functions. It covers scope, closures, objects, prototypes, arrays, higher-order functions, and asynchronous programming. Additionally, it highlights modern ES6+ features and advanced patterns for efficient coding practices.

Uploaded by

ZewduErkyhun
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Fundamentals

• let (block-scoped, reassignable), const (block-scoped, not reassignable), var (function-scoped,


hoisted – avoid).
• Primitive types: string, number, boolean, null, undefined, symbol, bigint (copied by value).
• Objects (arrays, functions, objects) are reference types (copied by reference).
• Use === instead of == to avoid coercion issues.
• Falsy values: false, 0, '', null, undefined, NaN.
• Control flow: if/else, switch, for, for...of, for...in, while.
• Functions: declaration (hoisted), expression, arrow (no own this), IIFE.

2. Scope & Closures

• Lexical scope: scope determined by where variables are defined.


• Block scope introduced with let/const (ES6).
• Hoisting: function declarations fully hoisted; var hoisted as undefined; let/const in TDZ.
• Closure = function + remembered lexical environment.
• Used for private variables, factory functions, currying, module patterns.

3. Objects & Prototypes

• Objects store key-value pairs and methods.


• Destructuring for clean extraction.
• this depends on how function is called.
• Prototype chain enables inheritance ([Link], __proto__).
• ES6 classes are syntactic sugar over prototype-based inheritance.

4. Arrays & Higher-Order Functions

• Core methods: map (transform), filter (remove), reduce (accumulate), find, some, every.
• Higher-order functions take or return other functions.
• Prefer immutability using spread operator.
• Avoid mutating arrays directly in modern applications (especially React).

5. Asynchronous JavaScript

• Single-threaded with Event Loop.


• Execution order: Call Stack → Microtasks (Promises) → Macrotasks (setTimeout).
• Callbacks (older pattern, can cause callback hell).
• Promises: pending → fulfilled → rejected.
• async/await simplifies Promises; use try/catch for errors.

6. Modern ES6+ Essentials

• Modules: export default, named exports; import syntax.


• Template literals with interpolation ${}.
• Spread (...) copies; Rest (...args) collects.
• Optional chaining (?.) prevents crashes.
• Nullish coalescing (??) handles null/undefined only.

7. Advanced Patterns

• Debounce: delay execution until activity stops.


• Throttle: limit execution rate.
• Event delegation: attach listener to parent for dynamic children.
• Memory management: avoid leaks (remove listeners, clear intervals).

You might also like