Skip to content

Commit e20d86b

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

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

‎js codes.docx‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,5 +2812,31 @@ WeakMap: It's similar to WeakSet where can't able to iterate and only stores an
28122812
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.
2815+
============================================================================================================================================================================
2816+
2 ways of Curring function with closures:
2817+
2818+
2819+
*****Using Normal Function******
2820+
2821+
function add(a){
2822+
return function(b){
2823+
if(b) return add(a+b);
2824+
return a;
2825+
}
2826+
}
2827+
console.log('Sum :', add(1)(2)(3)(4)(5)(6)(7)(8)()) //"Sum :", 36
2828+
28152829

2830+
*****Using Arrow Function******
2831+
2832+
function sum(num1) {
2833+
return (num2) => {
2834+
if(!num2) {
2835+
return num1;
2836+
}
2837+
return sum(num1 + num2);
2838+
}
2839+
}
2840+
console.log('Sum :', sum(1)(2)(3)(4)(5)(6)(7)(8)()) //"Sum :", 36
2841+
=====================================================================================================================================================================
28162842

0 commit comments

Comments
 (0)