17.
What will be the output of the following code?
function greet()
{ console.log("Hello!");
}
var sayHello = greet;
sayHello();
sayHello
ReferenceError: greet is not defined
undefined
Hello!
Correct: D
The code defines a function called greet that logs Hello!. Then, the variable sayHello is assigned the value of the greet function. Finally, the sayHello function is invoked, which outputs Hello! to the console. Therefore, the correct answer is Hello!.