30.
What is the syntax for declaring an arrow function in ES6?
function params() { // code here }
function(params) { // code here }
params => { // code here }
(params) => { // code here }
Correct: C, D
In ES6, arrow functions are a shorter syntax for writing function expressions. They are declared using the params => { // code here } syntax, where params represents the function's parameters. Arrow functions are commonly used for writing concise and readable code, especially when working with array methods like map, filter, and reduce.
const square = x => {
return x * x;
};
const add = (a, b) => {
return a + b;
};