I have the following constructor:
function Person(name, age) {
this.name = name;
this.age = age;
}
Now if I say:
var p = new Person("jon", 25);
It will create an instance Person, but what if the user does the following:
var p = Person("jon", 25);
This will lead to the definition nameand ageobject window.
My question is, is there a way to prevent the user from calling directly Personwithout newand thus prevent the addition of an object window?
user5533899
source
share