JavaScript Flashcards
What is JavaScript?
A scripting language for creating dynamic web page content.
ecmascript
A standard on how a language should work (ex. javascript) and what features it should have.
Destructuring
a faster way to access data from arrays, objects, and maps by setting each value as new variables.
map (array method)
map creates a new array by calling a function on every array element. It does not change the original array.
spread operator (ES6) (…)
allows you to quickly copy all or part of an existing array or object into another array or object using “…”
rest operator (…)
allows a function to take an indefinite amount of arguments and bundle them in an array. The rest parameter must be placed at the end of the arguments to gather all remaining arguments.
preventDefault (method)
method that tells the form we’ll handle what happens when a form is submitted. By default, when a form is submitted, the information is sent through a URL.
named export vs default export
named export must use the same name. For default, you can come up with any name. You can only have one default export per file. example for named export: “export const books …”. example for default export: “export default books”.
named import vs default import
named import must be the same name. for default export, we can come up with whatever we want. example- for named import: “import {books} from “./books.js””. example for default import “import banana from “./books.js””.
synchronous
Tasks are completed one after another. JavaScript is synchronous and single-threaded.
asynchronous
Tasks are completed parallel to one another. This is a lot better performance-wise than synchronous. In JS, async is provided by Events. Async patterns include - callbacks, promises, and async/await.
Blocking
Blocks the execution. This is synchronous.
Non-blocking
Does not block the execution of further-operations. This is mainly asynchronous. Non-blocking is more performant than blocking code.
event
An event is JS interaction with HTML elements. Such as when the page loads, or when a button is clicked.
event loop
A constantly running process that coordinates the tasks between the call stack and callback queue to achieve concurrency.
callback queue
A queue that keeps all callback functions ready for execution and executes after the call stack is empty. This operates on the FIFO principle. The callback functions are pushed to the call stack to execute when the event loop finds an empty call stack.
callback
a function passed as an argument to another function.
promise
an object that represents the eventual success or failure of an asynchronous task and its resulting value.
.then() promise method
When the promise is resolved/fulfilled, you can access the data and display the data within this method. It immediately returns an equivalent Promise object, allowing you to chain calls to other promise methods- creating a promise chain.