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.
Select the number from among the given options that can replace the question mark (?) in the following series. 85, 84, 92, 65, 129, ?
Select the correct option that indicates the arrangement of the given words in the order in which they appear in an English dictionary.
1. Formal...
Which of the answer figures is the exact mirror image of the given problem figure when the mirror is held at the right side?
Problem figure:
Select the option figure in which the given figure is embedded as its part (rotation is NOT allowed).
Neeta is teaching relations to her daughter. She says, "How is my mother's mother's daughter-in-law's daughter related to me?" What will be the correct...
Select the correct option from the following options which could create a full square (3 out of 5 images below):
Select the option that is related to the fifth letter-cluster in the same way as the second letter-cluster is related to the first letter-cluster and th...
Sunil starts walking from Point R. He walks 28 m towards the west, turns right and walks for 20 m to reach point M. He then takes a left turn, walks for...
Statements: Some chargers are metal. All metal are hard. Some hard are stools.
Conclusion I: All chargers are metal.
Conclusion II: Some stools are hard.
Five friends, Purva, Roshan, Vibhor, Luna and Anuj, are wearing five different coloured T-shirts, red, black, purple, yellow and blue. Each of the frien...