Q
Which statement correctly declares a JavaScript arrow function?

Answer & Solution

Answer: Option A
Solution:
Option A correctly declares a JavaScript arrow function named 'add' that takes two parameters 'a' and 'b' and returns their sum using the arrow function syntax. Arrow functions provide a concise way to write functions, especially for simple one-liners like this. Options B, C, and D use different syntaxes for function declaration but are not arrow functions. Therefore, option A is the correct way to declare an arrow function in JavaScript.
Related Questions on Average

What is the purpose of the 'this' keyword in JavaScript?

A). To refer to the current HTML element

B). To refer to the current JavaScript file

C). To refer to the current object

D). To refer to the current function

How can you add a new element to the end of a JavaScript array?

A). colors.push('blue');

B). colors.add('blue');

C). colors.insert('blue', colors.length);

D). colors[colors.length] = 'blue';

How do you concatenate strings in JavaScript?

A). Using the + operator

B). Using the - operator

C). Using the * operator

D). Using the / operator

What is the purpose of the 'break' statement in a JavaScript switch case?

A). To continue to the next case

B). To exit the switch statement

C). To restart the switch statement

D). To execute the default case

What is the purpose of the 'return' statement in a JavaScript function?

A). To end the function execution

B). To return a value from the function

C). To print a value to the console

D). To declare a variable

Which statement correctly declares a JavaScript array?

A). let colors = ['red', 'green'];

B). const colors = {'red', 'green'};

C). const colors = ['red', 'green'];

D). var colors = ('red', 'green');

How can you prevent a JavaScript function from executing immediately?

A). Using async/await

B). Using the defer attribute in HTML script tag

C). Wrapping the function in parentheses

D). Using the setTimeout function

What is the purpose of the 'continue' statement in a JavaScript loop?

A). To exit the loop

B). To skip the current iteration

C). To restart the loop

D). To execute the loop body again

How do you access the last element of a JavaScript array?

A). colors[colors.length - 1];

B). colors.last();

C). colors[-1];

D). colors.getLast();

Which operator is used for strict inequality in JavaScript?

A). !==

B). !=

C). <>

D). /=