A default value lets a function parameter receive a predefined value when the caller supplies no argument. JavaScript added default argument syntax with ECMAScript 2015, alongside other major language features that replaced large, infrequent releases with yearly evolution. section 1.1
In functional code, defaults can make initial state explicit without separate setup or variable reassignment. They are especially useful when a recursive function carries state through parameters. section 4.3.2
Initializing recursive state
The first call to computeCipher(data) starts with i = 0 and hash = 0. Recursive calls then provide updated values explicitly, while the defaults preserve the intended initial state. section 4.3.2
Listing 4.7 Refactoring computeCipher as a recursive function
function computeCipher(data, i = 0, hash = 0) {
if(i >= data.length) {
return hash ** 2;
}
return computeCipher( #1
data,
i + 1,
((hash << 5) - hash + data.charCodeAt(i)) << 0
);
}
Inspect the recursive computeCipher implementation to see default parameters establish initial state before each recursive call advances the computation. section 4.3.2



















