Close

Author Łukasz Świątkowski

Łukasz Świątkowski

Different ways of handling default values of parameters in JavaScript

The problem Assume we have a function, which expects three parameters that have to be added, then returned as a sum. It can be defined this way: Now, assume that the second parameter should have default value equal to 0, and the last one – equal to 2. In ES6 we would write: But usually […]