Glossary Flashcards
When is code Asynchronous?
Code is asynchronous when you initiate something, forget about it, and when the result is ready you get it back without having to wait for it. It might take even seconds and in the meantime you complete other stuff, and when the response it ready, the callback function gets called.
What’s an example of Asynchronous?
AJAX call.
What’s a modern way to handle async?
Promises and async
In JavaScript, Block is created by?
curly braces {}.
eg.) if statement contains a block, a for loop contains a block.
Block Scoping
When a variable in a block is visible and accessible from inside the whole block, but not outside of it.
Callback
A callback is function that’s invoked when something happens.
eg.) A click event associated to an element has a callback function that’s invoked when the user clicks the element. A fetch request has a callback that’s called when the resource is downloaded.
Declarative
A declarative approach is when you tell the machine what you need to do, and you let if figure out the details.
Why is React considered declarative?
Because you reason about abstractions rather than editing the DOM directly.
A “Fallback” is used for?
Is used to provide a good experience when a user hasn’t access to a particular functionality.
eg.) a user that browses with JavaScript disabled should be able to have a fallback to a plain HTML version of the page. Or for a browser that has not implemented an API, you should have a fallback to avoid completely breaking the experience of the user.
Function Scoping
Any variable defined in a function is visible and accessible from inside the whole function.
Immutability
A variable is immutable when its value cannot change after it’s created.
Mutable
A variable that can be changed.
Lexical Scoping
A particular kind of scoping where variables of a parent function are made available to inner functions as well.
Polyfill
A way to provide new functionality available in modern JavaScript or a modern browser API to older browsers.
Pure Function
A function that has no side effects (does not modify external resources), and its output is only determined by the arguments. You could call this function 1M times, and given the same set of arguments, the output will always be the same.