JS advance Flashcards
What does this code do?
const wrap = value => () => value;
return a function
In JavaScript, when is a function’s scope determined; when it is called or when it is defined?
JS function scope is determined when we call a function. This is because JavaScript uses a feature called “lexical scoping” or “static scoping,” where the scope of a function is based on its location in the source code when it is invoked.
What allows JavaScript functions to “remember” values from their surroundings?
closures
What is this?
This keyword is a reference to the object which is executing current function.
If use regular function method on object this is going to refer to global object!
In strict mode it will be undefined.
Arrow functions does not create its own execution context but inherits the this from the outer function where the arrow function is defined.
The value of this depends on how and where a function is called, and it can change dynamically during runtime.
What is event loop?
Built-in libuv (library) mechanism called the event loop, which handles the execution of asynchronous functions.
What are closures?
Closures is when a function remembers and continue to access variable from outside its scope, even when the function is executed in different scope.
What is promise object?
The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
What is async/await?
The async/await keywords enable asynchronous, promise-based behavior to be written in a cleaner style.
It’s alternative to .then method.
shallow/deep copy
A deep copying means that value of the new variable is disconnected from the original variable while a shallow copy means that some values are still connected to the original variable. by Reference
What are Classes in JavaScript?
Classes are custom data structures (objects) that includes both data and behaviors that operate on that data.
Typeof Class is a function.
What does JavaScript runtime environment mean.
JavaScript runtime environment refers to where your program is being executed. Might be executed in browser or Node.js. Front-end JavaScript aps are executed in browser and have access to window object. Back-end JavaScript aps are executed in the Node environment and have access to the file system, databases, and networks attached to the server.
What is Restful API?
A RESTful API is an interface that two computer systems use to exchange information securely over the Internet.
A REST stands for Representational State Transfer.
What does script mean?
In computer programming, a script is a program or sequence of instructions that is interpreted by another program rather than by the computer processor.
Solution Stack
In computing, a solution stack or software stack is a set of software subsystems or components needed to create a complete platform such that no additional software is needed to support applications.
What is hoisting in JS?
Hosting is JavaScript’s default behavior of moving all functions and declarations “to the top” of the current scope prior to execution of the code. Let, const and arrow functions are hoisted but they are not initialized as undefined.
What is Event Delegation pattern?
We add one event listener to a parent element. And then we can execute different functions base on which children element was clicked (which tagName) This works because event bubbling.
let birds = document.querySelectorAll(‘li’)
for( const bird of birds) {
if (bird.matches(‘.endangered’)) {
console.log(‘whee’)
}
}
What does Block Scoping mean?
The Block Scope is a set or rules that manages the accessibility and visibility of variables.
Block scope is useful for creating variables or constants that are only needed within a specific block of code, and it helps to prevent unintentional pollution of the global scope or unintended reassignments of variables.
Block Scoping determines where we can access particular variables or functions. Let and const scope is defined lexically by a block ( curly braces {} ,for, while, if statement) and they provide block-scoping.
A code block does not create a scope for var variables, but a function body does
A code block in JavaScript defines a scope for variables declared using let and const:
The inner scope can access the variables of its outer scope.