JS Fundamentals 1 Flashcards
ECMAScript
JS standardization for browsers.
The “ES” in ES5, ES6, etc.
ES6 - 2015
Transpilers and Polyfills are used to help fill in browser limitations.
JS Runtime
Engine that interprets JS code.
Can be part of a browser, server, or other runtime env
Single-Threaded Runtime
This is the Defining Feature of JS.
Runtime consists of a Stack and a Queue.
An Event Loop takes work from the Queue to the Stack.
Shadow DOM
Creates a boundary around part of the UI that prevents a parent from changing a child.
It does this by forcing events started across the boundary to rescope their targets.
Object Literal Notation
Declarative.
const bike = { gears: 10 }
Best for one-off objects.
New Objects with Constructors
Best for creating 2 or more objects with the same properties.
3 shapes of properties (on an object)
Primitives
Objects
Arrays
6 Primitive types
String
Number
Boolean
Null
Undefined
Symbol (value guaranteed to be unique)
Prototype Inheritance
A prototype is an object that sits in memory and defines properties or functions.
Objects that share the same prototype inherit those properties.
Class-based Inheritance
JS does not have true class-based inheritance.
Constructor functions are syntactical sugar for Prototypal Inheritance.
DOM events / browser events relation to JS
DOM and browser events are not part of JS.
They are APIs implemented for JS in the browser.
Runtime events path
Event is emitted in Runtime.
Message is created in the Engine.
Message placed in the Event Queue.
Once the Stack is free, the Event Handler is invoked, creating a Frame on the Call Stack.
Function Declaration
A statement that uses the ‘function’ keyword to create a function.
These can be called BEFORE they are declared.
Function Expression
A function created with a variable.
These must be called AFTER they are declared.
const doubleUp = (num) => {}
Factory Function
A pattern where a function returns a function.
Useful for one-off reusable functions, especially to capture variable references in a closure.