#default-parameter
Read more stories on Hashnode
Articles with this tag
Below is an example. const obj1 = {}; const obj2 = { k: 2 }; function fn({ k = 1 }) { console.log(k); } fn(obj1); // 1 fn(obj2); // 2
Concept Please check the codes below. function fn({ k1 = 1 }) { return k1; } console.log(fn('Put whatever you want here.')); The conclusion of the...