Le 01/01/2012 06:12, John J Barton a écrit : > On Sat, Dec 31, 2011 at 7:53 PM, Axel Rauschmayer <[email protected] > <mailto:[email protected]>> wrote: > > > > 1. Checking whether a variable has been declared. > Problematic: verbose and conflated with checking for a > declared variable having the value `undefined`. > Better: a dedicated operator or predicate for performing this > check. > > > Sorry, I don't think anyone checks if a is variable declared. You just > look at the source code. I have read code where people checked variable existence in global code. Typeof prevents a ReferenceError if the variable is not declared. Having been used to do it in global code (where you can't always "read the code"), or just reading it somewhere, people reproduce within a function.
I agree that there are a lot of bad practices in here, but some people do do it. Moreover, the concept of static scoping and "just look at the code to see if a variable is declared" is not that obvious for newcomers to the language or newcomers to programming. David
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

