SimpleFn.js

//SimpleFn with var and let Keywords var simpleFn = () => { //function scope if(true) { let a = 1; var b = 2; console.log(a) console.log(b) } //if block scope console.log(b) //function scope console.log(a) //function scope }
To make the point concrete, we can write the same function with var and the let keyword, inside an if block as shown in Listing

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.