To find whether an object was constructed by a certain constructor or one inheriting from it, you can use the instanceof command:
//We want this function to take the sum of the numbers passed to it
//It can be called as sum(1, 2, 3) or sum([1, 2, 3]) and should give 6
function sum(...arguments) {...