- A function is a parametric block of code defined once and called multiple times later. In JavaScript a function is composed and influenced by many components:
a) JavaScript code that forms the function body.
b) The list of parameters.
c) The variables accessible from the lexical scope.
d) The returned value.
e) The context this
when the function is invoked.
f) Named or an anonymous function.
g) The variable that holds the function object.
h) arguments object (or missing in an arrow function).
- var and let are both used for variable declaration in javascript but the difference between them is that var is function scoped and let is block scoped.
A variable declared with var is defined throughout the program as compared to let.
- In programming, a pure function is a function that has the following properties:
- The function always returns the same value for the same inputs.
- Evaluation of the function has no side effects. Side effects refer to changing other attributes of the program not contained within the function, such as changing global variable values or using I/O streams.