JavaScript Flashcards
Describe scope in Javascript?
In javascript, there are two kinds of scope. Global scope and function scope. If the variable definition happens inside of a function the variable is defined with function local scoped. Otherwise, the variable is defined with a global scope meaning it’s created as a member of a global object
What is hoisting?
Hoisting is when the javascript interpreter assigns variable declarations a value of undefined when it’s evaluating the code.
What is the difference between let and var?
var is function scoped and when accessed before initialized returns undefined. let is block scoped and returns a reference error when accessed before initialization.
what’s the difference between const and let?
const and let are both block-scoped and return reference errors when accessed before initialization. The only difference is that const cannot be reassigned, but it is mutable.
What is an async function?
An async function is an asynchronous function, it always returns a promise.
What is a promise?
A promise in javascript is a way to return a value in a way that is time-independent. with a promise you can specify chains of asynchronous steps, using the .then(…) method on a returned promise.
What is a pure function?
A pure function takes arguments and returns values based on those arguments.
What is an impure function?
Impure functions can mutate objects outside of their scope or produce side effects.