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

Which operator is used for strict inequality in JavaScript?

A). !==

B). !=

C). <>

D). /=

How do you concatenate strings in JavaScript?

A). Using the + operator

B). Using the - operator

C). Using the * operator

D). Using the / operator

How can you convert a string to a number in JavaScript?

A). parseInt('10')

B). parseFloat('10.5')

C). Number('10')

D). All of the above

What is the correct way to declare a JavaScript class?

A). class Rectangle {}

B). let Rectangle = {}

C). function Rectangle() {}

D). Rectangle {}

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

Which statement correctly declares a JavaScript function?

A). function greet() {}

B). const greet = function() {}

C). const greet = () => {}

D). const greet = {}

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

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

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 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';