Variables
Variables can be denoted with the keywords let or const. The accepted convention is to use const as much as possible, and let when the variable is likely to be re-assigned
JavaScript concepts in 30 words or fewer, with code to make them stick. Pick a topic to get started.
Variables can be denoted with the keywords let or const. The accepted convention is to use const as much as possible, and let when the variable is likely to be re-assigned
Functions in Javascript consist of the function keyword followed by the name of the function, a list of parameters and statements that define the function.
Functional expressions load only when the interpreter reaches that line of code. They're not hoisted, allowing them to retain a copy of the local variables from the scope where they were defined. They do not polute the global scope.
The condition is evaluated as a boolean. If the condition is true it returns the first expression, else it returns the second condition.
There are three logical operators in JavaScript:
A for loop creates a loop with three optional expressions; enclosed in parentheses and separated by semicolons, followed by a statement (usually a block statement) to be executed within the loop.
A while loop loops through a block of code "while" the condition is true.
A switch statement is an alternative to multiple if statements. Switch statements are a more efficient way to code when testing multiple conditions.
A concise syntax for creating functions. If we have only one argument, then parentheses around parameters can be omitted. Arrow functions do not have a 'this' context.
ES6 syntactic sugar that allows us to program in a more object-orientated way. It allows us to define a constructor together with its prototype methods.
Scope refers to the current context of code, which determines the accessibility of variables to JavaScript.
A Call Stack is a data structure that stores and manages function invocations. A kind of 'To-do list' for Javascript that uses the Last In, First Out (LIFO) principle.
The Event Loop monitors the Call Stack and the Callback Queue. If the Call Stack is empty, it pushes the first event from the queue to the Call Stack.
An IIFE (Immediately Invoked Function Expression) is a JavaScript function that runs as soon as it is defined. Variables declared inside the IIFE have private scope.
A function within another function. A nested function can 'inherit' the arguments and variables of its containing function. Put simply; the inner function contains the scope of the outer function.
Recursion is a technique for iterating over an operation by having a function call itself repeatedly until it arrives at a result. Most loops can be rewritten recursively.
Memoization is the programmatic practice of making recursive/iterative functions run faster by caching the values that the function returns after its initial execution.
The combination of a function and the environment in which it was declared. In Javascript all functions form closures. A common use case is creating private functions.
Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution.
Currying is the process of transferring a function with many arguments into the same function with fewer arguments. Allowing you to partially apply functions and pass them to higher-order functions.
Pass by value means the actual value is passed on. Pass by reference means a number (where the value is stored in memory) is passed on.
Javascript is a single-threaded language. Meaning it performs one action at a time. Asynchronous Javascript is a way to perform multiple actions simultaneously using callbacks, promises, and async/await.
A promise is an object that may produce a value sometime in the future. Either a resolved value or a reason that it’s not resolved (e.g., a network error occurred).
Async/Await is syntactic sugar that makes promises easier to work with. It allows us to write asynchronous code that's similar in appearance to synchronous code.
A Global Object is an object that always exists in the global scope. In a browser, the Global Object is the 'Window' and in Node.js the object is Global.
The “this” keyword allows you to decide which object should be focal when invoking a function or a method; effectively allowing you to reuse functions with different contexts.
With call you can write a method once, and then inherit it in another object, without having to rewrite the method for the new object.
The only difference between apply() and call() is that the second parameter of the apply() method accepts the arguments to the actual function as an array.
Similar to call and apply except bind() returns a function instead of a value. It sets the value of 'this' and returns a function. It does not invoke the function.
Inheritance is simply one object trying to inherit properties and methods of another object. A prototype is simply an object with inbuilt methods that are attached to your object.
Polymorphism Is the practice of designing objects to share behaviors and to be able to override shared behaviors with specific ones. Polymorphism utilizes inheritance in order to make this happen.