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.
A train 150 meters long crosses a man running in the same direction at a speed of 9 km/h in 15 seconds. It then crosses a platform in 25 seconds. Find t...
How far will 'Neha' travel by the time she catches up to 'Simran', given that 'Neha' starts 75 km behind and moves at 60 km/h while 'Simran' moves at 45...
1500 metres long train crosses a man who is moving in the same direction with a certain speed, in 50 seconds. If the same train can cross a tree in 15 s...
A motor-cycle covers 160 km with a speed of 70 km/hr. find the speed of the motor-cycle for the next 170 km journey so that the average speed of the who...
A boy goes to school with a speed of 50 km/h and comes back with a speed of 30 km/h. find his average speed?
A train moves at 90 km/h and needs to cover a journey in 2 hours. It halts for 10 minutes at the midpoint. What speed must it take for the second half?
The diameter of a wheel W is 63 cm. It completes 1000 rotations in 1 minute. Find the speed of the vehicle.
- A train was moving at 60 km/hr for ‘x’ hours. It then increased its speed by 10 km/hr and travelled for (x + 4) hours. If it covered 910 km in the seco...
 A, B, and C run around a Circular track starting from the same point simultaneously and in the same direction at 6 km/h, 12 km/h, and 18 km/h respect...
A train covers a certain distance at a speed of 36 km/h and the next same distance with a speed of 45 km/h and the next same distance with a speed of 60...