Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of scoping rules in JavaScript
/* Scoping Rules - let, const, var */
function test() {
//Block Scope
{
var b = 7;
const a = 3;
let c = 22;
console.log(a, b, c);
}
//b is still defined.
console.log(b);
//a, and c are not defined
console.log(a, c);
}
test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment