11.
What will be the output of the following code? var multiply = (x, y) => x * y; console.log(multiply(3, 4));
12.
How can you define a method inside an object?
13.
What is the output of the following code? var person = { name: "Alice", greet: function() { return "Hello, " + this.name; } }; console.log(person.greet());
14.
How do you create an Immediately Invoked Function Expression (IIFE)?
15.
What will be the output of the following code? var counter = (function() { var count = 0; return function() { return ++count; }; })(); console.log(counter()); console.log(counter());
16.
Which of the following is true about functions in JavaScript?
17.
How do you define a function using a function expression?
18.
What will be the output of the following code? var add = new Function('a', 'b', 'return a + b'); console.log(add(2, 3));
19.
How can you store a function as a property of an object?
20.
Which of the following is an example of using a function as a return value?