Js Flashcards
Hosting
Hoisting in Javascript is when Javascript moves variable declarations (NOT definitions) up to the top of its global or local scope. This means that var , const , and let variable declarations are interpreted as if it is at the top of its scope.
Therefore, a constant variable must be both declared and initialised before use. As a prologue to this section, it’s important to note that indeed, JavaScript hoists variables declared with es6 let and const. The difference in this case is how it initialises them.
The JavaScript engine hoists the variables declared using the let keyword, but it doesn’t initialize them as the variables declared with the var keyword. The JavaScript engine doesn’t hoist the function expressions and arrow functions.
Lexical scope in Js ES6
a variable defined outside a function can be accessible inside another function defined after the variable declaration. But the opposite is not true; the variables defined inside a function will not be accessible outside that function.
Fetch api with Vanilla Js
The fetch() method returns a Promise. We can handle API responses using then() and catch().
fetch(‘https://jsonplaceholder.typicode.com/posts’).then(function (response) {
// The API call was successful!
console.log(‘success!’, response);
}).catch(function (err) {
// There was an error
console.warn(‘Something went wrong.’, err);
});
https://gomakethings.com/how-to-use-the-fetch-api-with-vanilla-js/
Vanilla Js
https: //www.google.com/amp/s/www.geeksforgeeks.org/7-javascript-concepts-that-every-developer-must-know/amp/
https: //www.google.com/amp/s/www.boardinfinity.com/blog/top-10-features-of-es6/amp/