I have a constructor where name is a string and details should be an array containing animal type, age and colour.:
function animal(name, details) {
this.animal_name = name;
this.animal_details = details;
}
I want to create a new object from this prototype:
var myPet = new animal("Olly", " /* what goes here? */ ");
How do I declare the array in this case (is it like the usual array declaration) How do I use this when creating a new object myPet?
NB: This is my previous way of doing this without using an array:
function meal (starter, main, side, dessert, drink) {
this.starter = starter;
this.main = main;
this.side = side;
this.dessert = dessert;
this.drink = drink;
}
var myMeal = new meal("soup", "chicken", "garlic bread", "cake", "lemonade");