ES6 doesn't need opt-in

David Bruant bruant.d at gmail.com
Sun Jan 1 05:12:48 PST 2012


Le 01/01/2012 06:12, John J Barton a écrit :
> On Sat, Dec 31, 2011 at 7:53 PM, Axel Rauschmayer <axel at rauschma.de
> <mailto:axel at rauschma.de>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120101/eed98c5f/attachment.html>


More information about the es-discuss mailing list