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.
15.99% of 549.99 ÷ 11.17 = ? ÷ 20.15
74.91% of 639.95 – 599.98% of 45 + 119.987 = ?
(4.88 × 5.76)2 - ?2 = 39.89 × 19.86
- What approximate value will come in place of the question mark (?) in the following question? (Note: You are not expected to calculate the exact value.)
- What approximate value will come in place of the question mark (?) in the following question? (Note: You are not expected to calculate the exactvalue.)
(1800.23 ÷ 29.98) + (816.32 ÷ 23.9) + 1634.11 = ?
1449.98 ÷ 50.48 × 10.12 = ? × 2.16
36.05 × 5.02 + 12.052 = ? + 9.09 × 4.04Â
(31.9)3 + (34.021)² - (16.11)3 - (42.98)² = ?