"" is an empty string vs null which means "does not exist".
In your case, you first compared name to "does not exist" which was false because name did exist. Then you compared name to empty string which is true because it has the value of an empty string.