Question: What is the result of the following JavaScript code? function Person(name) { this.name = name;}var person1 = new Person("Alice");var person2 = new Person("Bob");console.log(person1.name);
Answer:
The person1 object is created with the name "Alice," and console.log(person1.name) logs "Alice."
MCQ: What is the result of the following JavaScript code? function Person(name) { this.name = name;}var person1 = new Person("Alice");var person2 = new Person("Bob");console.log(person1.name);
Correct Answer:A. "Alice"
Explanation:
The person1 object is created with the name "Alice," and console.log(person1.name) logs "Alice."