Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript JavaScript error function not defined Reply To: JavaScript error function not defined

#245992
Redfredg
Participant

Frankly, hoisting should’ve been removed so “var” works correctly, and there would never be a need for “let” (which is a rubbish word and feels like 80s BASIC programming on the ZX Spectrum). It seems ridiculous to just introduce a new declaration that works properly, yet keeping the old one in. Would’ve been backwards compatible too. I can understand your point of view and it’d be quite cleaner. But it wouldn’t be backwards compatible due to the facts named below but also because even if you should declare variables within the corresponding scope, there’s never a guarantee that they really are. Changing the hoisting behavior would crash millions of websites and that’s not acceptable. But it’d have been possible to just allow coders to define something like “use-strict” for the ECMAScript version they’re using in their scripts. That would be backwards compatible since authors would expect var to act like let when they define ECMAScript 6 in their scripts.

Thanks !!
[email protected] redgage