Js Flashcards

1
Q

Hosting

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Lexical scope in Js ES6

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Fetch api with Vanilla Js

A

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/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Vanilla Js

A

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/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly