1/25
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Primitive data types
Immutable values stored by value. Includes: string, number, boolean, null, undefined, symbol, bigint.
Reference data types
Stored by reference (memory address). Includes: objects, arrays, functions.
Difference between primitive and reference types
Primitives are copied by value, references are copied by memory reference.
var
Function-scoped, hoisted with undefined, can be redeclared and reassigned.
let
Block-scoped, hoisted but in Temporal Dead Zone, can be reassigned but not redeclared.
const
Block-scoped, must be initialized, cannot be reassigned.
Can const objects be mutated?
Yes, object properties can change, but the variable binding cannot.
Hoisting
JavaScript moves declarations of variables, functions, and classes to the top of their scope before execution.
Are variables hoisted?
Yes, but only declarations, not initializations.
Why block scope is important
Prevents accidental variable access and bugs.
Closure
A function that remembers variables from its outer scope even after the outer function has finished executing.
Common closure use cases
Data encapsulation, private variables, callbacks, event handlers.
Example of closure
function outer() {
let x = 10;
return function inner() {
return x;
}
}
this keyword
Refers to the object that is executing the current function
this in global scope
In browser: window; in strict mode: undefined.
call()
Invokes a function immediately with a specified this and arguments passed individually.
apply()
Invokes a function immediately with a specified this and arguments as an array.
bind()
Returns a new function with permanently bound this.
Difference between call and apply
call uses arguments list, apply uses arguments array.
When to use bind
When passing methods as callbacks and you want fixed this.
What is JavaScript?
A high-level, interpreted, dynamically typed programming language.
Is JavaScript single-threaded?
Yes, it runs on a single call stack.
What is the event loop?
A mechanism that handles asynchronous operations by pushing callbacks from the task queue to the call stack.
JavaScript runtime
Environment that executes JS (Browser, Node.js).
Why JS is non-blocking
Because async tasks are handled via Web APIs and the event loop.