22.
What will be the output of the following code?
function greet(name) {
console.log(`Hello, ${name}!`);
}
const person = {
name: "Alice",
greet: greet,
};
person.greet(person.name);
ReferenceError: greet is not defined
TypeError: person.greet is not a function
Hello, Alice!
Hello, name!
Correct: C
The code defines a function greet that takes a parameter name and logs a greeting message using the console.log() method. Then, it creates an object person with a property name set to "Alice" and a method greet assigned to the greet function. Finally, the code calls the greet method of person object with the argument person.name, which is "Alice". Therefore, the output will be Hello, Alice! printed to the console.