javascript check if function is not undefined