Let's say I have the following constructor function
function Planet(solarSystem,habitable) {
this.solarSystem = solarSystem;
this.habitable = habitable;
}
And I want to create an instance of this constructor function but I put the wrong parameters type (e.g. because I had 4 beers and I felt like programming):
let earth = new Planet(23, 'wooow');
Question: How can I condition the creation of the instance so that if parameter types are respected --> instance created, otherwise don't assign anything to earth
EDIT: I forgot to specify that I am expecting a Planet(String, boolean) parameters type
earthis not set to anything?