Default Parameters
When were default parameters introduced in JavaScript?
Default parameters were introduced in ES6 (ECMAScript 2015). This feature allows function parameters to have predefined values if no value or undefined is passed during invocation. Before ES6, developers had to use workarounds like the logical OR operator (`param = param || defaultValue`) or conditional statements to achieve similar functionality. These workarounds had limitations, particularly when dealing with falsy values that were valid inputs (such as 0 or an empty string). The introduction of proper default parameters in ES6 provided a cleaner, more intuitive syntax and resolved these edge cases. This addition was part of ES6's larger goal to enhance JavaScript's expressiveness and make common programming patterns more concise and less error-prone.