Well-commented JavaScript Sliding Window solution with Set - O(n) time O(n) space
right and left are pointers in the string -- for the maxLength = Math.max.... line we could also do ...Math.max(maxLength, right - left + 1) but set.size could 
```right``` and ```left``` are pointers in the string -- for the ```maxLength = Math.max....``` line we could also do ```...Math.max(maxLength, right - left + 1)``` but ```set.size``` could make more sense for some people.\n\nExplanation is under the code.\n\n```\nvar lengthOfLongestSubstring = function(s) {\n  if (!s.length) return 0;\n  \n  let left = 0, right = 0;\n  let maxLength = -Infinity;\n  const set = new Set();\n\n  while (right < s.length) {\n    // If s[right] has not been seen yet\n    if (!set.has(s[right])) {\n      // Add it to the set\n      set.add(s[right]);\n      // Increase size of window to right\n      right++;\n      // Update maxLength; set size represents length of unique substring\n      maxLength = Math.max(maxLength, set.size);\n    } else {\n      // We\'ve seen s[right] so we need to shrink the window\n      // Delete s[left] from set\n      set.delete(s[left]);\n      // Shrink window from left\n      left++;\n    }\n  }\n\n  return maxLength;\n}\n```\n\nFor example, in "abbc":\n\n1. left = 0, right = 0, ```s[right]``` = a, ```s[left]``` = a\n\t- set does not contain a, add to set\n```set = [a]```\n\t- Update maxLength to 1\n\t- Increment right\n2. left = 0, right = 1, ```s[right]``` = b, ```s[left]``` = a\n\t- set does not contain b, add to set\n```set = [a, b]```\n\t- Update maxLength to 2\n\t- Increment right\n3. left = 0, right = 2, ```s[right]``` = b, ```s[left]``` = a\n\t- set already contains b\n\t- Delete ```s[left]``` from set\n\t```set = [b]```\n\t- Increment left\n\n4. left = 1, right = 2, ```s[right]``` = b, ```s[left]``` = b\n\t- set already contains b\n\t- Delete ```s[left]``` from set\n\t```set = []```\n\t- Increment left\n5. left = 2, right = 2, ```s[right]``` = b, ```s[left]``` = b\n\t- set does not contain b, add to set\n\t```set = [b]```\n\t- maxLength does not change, since 1 < 2\n\t- Increment right\n6. left = 2, right = 3, ```s[right]``` = c,  ```s[left]``` = b\n\t- set does not contain c, add to set\n\t```set = [b, c]```\n\t- maxLength does not change, since 2 === 2\n\t- Increment right\n\n7. right = 4, which is out of bounds of the while loop\n8. Exit loop and return maxLength\n\n
['Sliding Window', 'JavaScript']