Which of the following is the correct way to declare an arrow function in JavaScript?

Which of the following is the correct way to declare an arrow function in JavaScript?

a) let myFunc = () => { ... }
b) let myFunc => () { ... }
c) let myFunc = () { => ... }
d) let myFunc => { ... }

Answer:

a) let myFunc = () => { ... }

Explanation:

An arrow function in JavaScript is declared using the => syntax. It is a shorter way to write functions and has different behavior with the this keyword compared to regular functions.

Example:


let add = (a, b) => a + b;
console.log(add(5, 10)); // Output: 15
    

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top