What is the difference between let and var in JavaScript?
The key difference is that 'var' has function scope, while 'let' has block scope. Variables declared with 'var' are either function-scoped or globally-scoped, meaning they're visible throughout the function or global context. Variables declared with 'let' are block-scoped, meaning they're only visible within the block (denoted by curly braces) in which they are declared. Additionally, 'var' variables are hoisted and initialized with undefined, while 'let' variables are hoisted but not initialized (resulting in a ReferenceError if accessed before declaration).