fast, short, intuitive JavaScript Solution using sets
Here is a solution that leverages a Set which only contains a word if all the letters in that word, minus the last, are already present in the set, as words.   
Here is a solution that leverages a Set which only contains a word if all the letters in that word, minus the last, are already present in the set, as words.   Faster than ~86% of submissions, as per my machine.\n\nNote: it uses the built in sort function as well as the builtin string.slice() functions. you can also use str.substr(0, str.length-1) , instead of slice.\n\n```JavaScript\n/**\n * @param {string[]} words\n * @return {string}\n */\nvar longestWord = function(words) {\n  words.sort();\n  let set = new Set();\n  let res = \'\';\n\n  for (let word of words) {\n    if (word.length === 1 || set.has(word.slice(0, -1))) {\n      set.add(word);\n      if (word.length > res.length) {\n        res = word;\n      }\n    }\n  }\n  return res;\n};\n\n```\n
['JavaScript']