Question
Which ES6 feature allows for function parameters to have
default values if no value is provided during a function call?Solution
Default parameters in ES6 enable a function to use a default value for a parameter if no argument is passed. This enhances code readability and reduces the need for conditional checks. Example: function greet(name = "Guest") { Â return `Hello, ${name}!`; } console.log(greet());Â Â Â Â Â Â // Outputs: Hello, Guest! console.log(greet("Alice"));Â Â // Outputs: Hello, Alice! This feature is especially useful in scenarios where optional parameters are involved, as it simplifies function declarations. ________________________________________ Why Other Options Are Incorrect: 1. Arrow functions: Arrow functions are a concise syntax for writing functions but do not relate to parameter defaults. 2. Template literals: Template literals allow embedding expressions in strings using backticks, unrelated to parameter handling. 3. Rest parameters: Rest parameters gather multiple arguments into an array, enabling flexible argument handling but do not assign defaults. 4. Destructuring assignment: Destructuring allows unpacking values from arrays or objects but does not deal with function defaults.
What is the total number of mock tests sold of SBI PO November and October together?
The number of mock tests sold of RBI Grade B Officer during December is approximately what percent of the number of mock tests sold of RBI Grade B offic...
If the sales team earned a profit of Rs 433 on each mock tests sold of SBI PO during September, what was his total profit earned on the mock tests of th...
What is the ratio of the total Sales of Sports shoes by Fila to the Sales of Sports shoes by Reebok?
What is the total sales of Sports shoes by Fila and Woodland together in Rs crore?
The cost of production of Track suits by Nike is approximately what percent more than the cost of production of Shoes by Reebok?
What is the ratio of profit earned by selling Track suits by Reebok to that by selling Shoes by Puma?
What is the total cost of Production of Desktop by HP and Dell together?
What is the profit earned by Lenovo on Laptops?
What is the difference between the profits earned by New Balance, Adidas by selling Shoes?