A simplified example:
function shorten(string) {
  return string.slice(0, 3);
}
const today = "Friday";
if (shorten(today) === "Fri") {
  console.log("Oh yeah it's " + shorten(today));
}
shorten(today) is called twice here, which makes me feel bad. I believe we all run into this situation every day, and what we do is store the the value of shorten(today) in a variable first, then use that variable twice. 
My question is: are modern JS engines smart enough so that I actually don't need to worry about it?
 
     
    