What are default parameters in JavaScript?

Answer

Default parameters (ES6) allow function parameters to have default values when no argument is provided or when undefined is passed. function greet(name = "World") { return "Hello, " + name; }. Passing null does NOT trigger the default — only undefined or omitting the argument does. Default values are evaluated at call time, not at definition time — allowing dynamic defaults: function createUser(id, timestamp = Date.now()) { }. Default values can reference previous parameters: function fn(a, b = a * 2) { }. Default values work with destructuring: function config({ timeout = 3000, retry = true } = {}) { } — the = {} makes the whole object optional. Default parameters completely replace the old pattern of name = name || "World", which had the falsy value problem.