Question 3 of 8Pro Only

What are the differences between var, let, and const in JavaScript, and when should you use each?

Sample answer preview

The three keywords differ along three axes: scope, reassignment, and redeclaration. Scope is the most consequential. var is function-scoped, meaning it is visible throughout the entire function that contains it regardless of which block it was declared in.

function scopeblock scopereassignmentredeclarationObject.freezeTemporal Dead Zone

Unlock the full answer

Get the complete model answer, key points, common pitfalls, and access to 7+ more Frontend Developer interview questions.

Upgrade to Pro

Starting at $19/month • Cancel anytime