最佳答案
包含一个空格的字符串长度总是等于1:
alert('My str length: ' + str.length);
空格是一个字符,所以:
str = " ";
alert('My str length:' + str.length); // My str length: 3
How can I make a distinction between an empty string and a string which contains only spaces? How can I detect a string which contain only spaces?