How can you create a function in Javascript?
A function is created with an expression that starts with the keyword function. Functions have a set of parameters and a body, which contain the statements to be executed when the function is called. The function body of a function created this way must always b wrapped in braces, even when it consists of only a single statement. A function can have multiple parameters or no parameters at all.
ex:
const function(param1,param2,âŚ){
[BODY - STATEMENTS GO HERE]
};
What is the difference between var and let in regards to scope?
let bindings are local to the block that they are declared in, so if you create a let inside of a loop the code before and after the loo can not âseeâ it.
Var bindings are visible throughout the whole function that they appear in - or throughout the global scope, if they are not in a function.
What is a pure function?
A pure function has a return vau that is the same for the same arguments (no variation with local static variables, non-local variables, mutatable reference arguments, or input streams from I/O devices. Also, a pure function does not have any side effects when evaluated (no change of variables or I/O streams).