Oh, come on now! That's too obvious for words.
In the first example, you have
<div id="box1"> </div>
and in the second example you have
So in the first example, the innerHTML of box1 is a single space, it is *NOT* "" that you are testing for.
In the second example, there truly is no content, so indeed the innerHTML *is* equal to "".
If you wanted to say "if the innerHTML is empty except possibly for spaces" you could do