Draw an example of a call stack and the functions that would need to be invoked to generate that call stack.
function firstFunction(){
console.log("Hello from firstFunction");
}
function secondFunction(){
firstFunction();
console.log("The end from secondFunction");
}
secondFunction();
secondFunction gets called first and put into the stackfirstFunction, pushing it into the stackfirstFunction logs Hello from firstFunction and is popped off the stacksecondFunction the moves up in the stack, is executed and logs The end from secondFunction and pops off the stack, clearing the memorydebugger adds a breakpoint to your code, allowing you to review the history of what has run up until that breakpointError Handling: Try Catch
(function testing(){
function add(a, b) {
try {
var result = a + b
return result.split('')
} catch (error) {
console.error('add went wrong ->', error)
return [] // default value
}
}
var stringResult = add("1", "2")
var numberResult = add(1, 2)
})();
try{} contains the code you want to executecatch{} contains the code you want to execute if there is an errorrequire(express) needs '' around express => require('express)username needs /req & res not referenced; change to request & responseres.send(userInfo)const userInfo {} has no object info insidelet cache = {
variable-name: {
data: <the data sent to the front end>
timeStamp: <time we put data in the cache>}
}
let key = searchedValue + 'Data';Also create a conditional statement within the call function to evaluate 1.) is there a cache and 2.) is it recent enough
if (cache[key] && cache[timeStamp]) {
//if data is cached && recent enough, return the cache data
} else {
//make a new request to the API
//put data into cache
}
cache[key] = {
data: <data-variable>,
timeStamp: Date.now()
}