Set a default parameter value for a JavaScript function

First Solution From ES6/ES2015, default parameters is in the language specification. function read_file(file, delete_after = false) { // Code } just works. Reference: Default Parameters – MDN Default function parameters allow formal parameters to be initialized with default values if no value or undefined is passed. Pre ES2015, There are a lot of ways, but…

Read more...