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

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 correct way to declare a variable in JavaScript?

A). var x = 10;

B). let x = 10;

C). const x = 10;

D). variable x = 10;

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 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 do you concatenate strings in JavaScript?

A). Using the + operator

B). Using the - operator

C). Using the * operator

D). Using the / operator

Which statement correctly declares a JavaScript module?

A). export function myFunc() {}

B). const myModule = function() {}

C). module.exports = myModule;

D). import myModule from './myModule.js';

What is the correct way to declare a JavaScript class?

A). class Rectangle {}

B). let Rectangle = {}

C). function Rectangle() {}

D). Rectangle {}

What does the '===' operator check in JavaScript?

A). Type and value equality

B). Type equality only

C). Value equality only

D). Reference equality

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