Professional Documents
Culture Documents
Promises is an object ,which represents the eventual completion or failure of the a synch operation’s.
b) fulfilled: completion
c) rejected: failed
Importance of promises:
***********************************************************************************************
2) j s hoisting:
Here
***********************************************************************************************
3) js anonymous function :
So
NOTE: Anonymous functions are used in a place where functions are used as values , by assigning to some variable.
***********************************************************************************************
***********************************************************************************************
5) rest and spread operator difference :
Rest operator:
function sum(a,b,…restp){
console.log(restp);
sum(1,2,3,4,5);
output: [3, 4, 5]
---------------------------------------------------------------------
rest operator should be last parameter --mentioned if it`s in middle then it shows error
----------------------------------------------------------------------
spread operator :
let arr=[1,2,3,5,4]
console.log(Math.min(...arr));
output:1;
**********************************************************************************************
CODING Question :
1) write a function to sum(a)(b)(c) :
function sum(a) {
return a + b + c
}
console.log(sum(1)(2)(3));
outpt-- // 6
const arr = [14, 58, 20, 77, 66, 82, 42, 67, 42, 4]
const min = arr.reduce((a, b) => Math.min(a, b))
console.log(min)
outpt-- //4