var str = " "; if(str == 'Пробелом'){ str = 'new'; }
var str = " "; if(str.replace(/\s/g,'')==''){ str = 'new new'; } alert(str.replace(/\s+/g,' '))