function Person(name) {
if (!name) {
throw new Error('Name is required');
}
this.name = name;
}
try {
const person = Person('John');
} catch (error) {
console.error('Failed to create person');
}
Even though there's error handling, calling Person without 'new' means 'this' refers to the global object before the error is thrown. If the name parameter is valid, the global object would be modified with a 'name' property. The try-catch only catches the thrown error but doesn't prevent the global scope pollution that occurs before that. Using 'new' or implementing a self-instantiating constructor pattern would prevent this issue.