|
|
|
|
|
by couchand
2998 days ago
|
|
It's purely syntactic sugar. You can even get the new protection yourself: function Cat() {
if (!(this instanceof Cat)) {
throw new Error("please use new!");
}
}
or, if you want to be a bit nicer to your users: function Cat() {
if (!(this instanceof Cat)) {
return new Cat();
}
}
|
|