function maxUniqSubStr(str) {
if (!str) { return ''; }
var map = { };
var maxLength = 1;
var maxStart = 0;
var start = 0;
map[str[0]] = 0;
for (var i = 1, le = str.length; i < le; ++i) {
var c = str[i];
var pos = map[c];
if (pos != null && pos >= start) {
if (maxLength < i - start) {
maxStart = start;
maxLength = i - start;
}
start = pos + 1;
}
map[c] = i;
}
if (maxLength < i - start) {
maxStart = start;
maxLength = i - start;
}
return str.substr(maxStart, maxLength);
}
alert(maxUniqSubStr('abcdeahopwunshslge'));