Right-hand side of 'instanceof' is not an object