Apr 16, 2017

[HDGEM] In JavaScript, blocks do not have scope, only functions have scope

An important difference between JavaScript and other languages like Java is that in JavaScript, blocks do not have scope; only functions have scope. So if a variable is defined using var in a compound statement (for example inside an if control structure), it will be visible to the entire function. However, starting with ECMAScript 2015, let and const declarations allow you to create block-scoped variables.

Posted By Blogger to HDGEM at 4/16/2017 04:51:00 PM