JavaScript

var scope leak in JavaScript

JavaScriptVariablesvar hoistingintermediate

What this snippet does

var ignores block scope like if/for, while let and const are confined to their block.

Expected output

3
let stays inside the block

Why practise typing this

Typing variables code builds muscle memory for the symbols and indentation JavaScript uses most, which prose-based typing tests never cover. DevType measures your words per minute and accuracy on this snippet and tracks the individual characters you mistype, so later lessons can target them.

More JavaScript practice

Browse all JavaScript snippets →