let
and const
have introduced block-level scoping to JavaScript, and I now understand the difference. But I'm yet to find a compelling real-world example where let
has an advantage over var
.
What does block-scoping offer in practical terms (illustrated by example)?