Use instanceof instead of constructor check