You should rather check if `typeof name == "object"`.