Skip to content

Commit fed56cb

Browse files
authored
Update js codes.docx
1 parent e20d86b commit fed56cb

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎js codes.docx‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2813,7 +2813,7 @@ Hoisting : Its related to memory management.
28132813
Global execution context having 2 component. In memory componenet variable and functions will store. Variable store with undefined and function store with prototype
28142814
of function. Var or functions will push to Callstack and then pop.
28152815
============================================================================================================================================================================
2816-
2 ways of Curring function with closures:
2816+
2 ways of Currying function with closures:
28172817

28182818

28192819
*****Using Normal Function******
@@ -2838,5 +2838,20 @@ function sum(num1) {
28382838
}
28392839
}
28402840
console.log('Sum :', sum(1)(2)(3)(4)(5)(6)(7)(8)()) //"Sum :", 36
2841+
2842+
*****Using Arrow ShortHand Function******
2843+
const sum = (a) => (b) => (c) => (d) => a+b+c+d
2844+
console.log('Sum :', sum(1)(2)(3)(4))
2845+
2846+
*****Using Partial Function******
2847+
function sum(...a){
2848+
return function(...b){
2849+
if(b?.length){
2850+
return sum([...a,...b].reduce((acc, curr)=>acc+curr,0))
2851+
}
2852+
return a;
2853+
}
2854+
}
2855+
console.log('Sum :', sum(1,2,3)(4,5)(6,7,8,9)()) //"Sum :", 36
28412856
=====================================================================================================================================================================
28422857

0 commit comments

Comments
 (0)