- No error is thrown if you declare the same variable twice using var (conversely, both let and const will throw an error if a variable is declared twice)2.
- So using var in this context would require a situation in which a variable declared inside a function would need to be used in the global scope.
- I conducted a quick search on the Internet revealed that Jslint.com and Jshint.com, and did not raise an issues with the use of var as a variable declaration.
- Simpson argues that:“There are going to be places in real world code where some variables are going to be properly scoped to the entire function, and for those variables, var is a better signal”He provides this code block to illustrate his point:Essentially, Simpson is arguing that while changing var with…
Continue reading “Should You Truly Never Use var? – John Wolfe – Medium”