> Same as...
> ( "globalUnknown" in this ) // anywhere
> ( "globalUnknown" in window ) // browser
> ( "globalUnknown" in global ) // node
> ( "globalUnknown" in self ) // workerglobalscope
>
> But this is _so_ common that it might warrant an upgrade
I’m not 100% sure but I was under the impression that scopes-as-objects will go
away in the long run. Then you wouldn’t be able to use the `in` operator, any
more. The first expression is nice in that it works on both browsers and
Node.js.
> // undefined and null in several variations
>
> var myvar;
> console.log(exists myvar); // false
>
> "exists" is misleading here, "myvar" does exist - you just initialized it,
> but did not assign a value. If I've understood 12.2 correctly, "myvar"
> definitely "exists"
Suggestions for better names welcome! isdefined ?
> var obj = {};
> console.log(exists obj.prop); // false
>
> This makes complete sense, but still same as my first example
>
> ( "prop" in obj )
It’s mainly there for reasons of symmetry to me, a variable having been
declared is the same as a property existing. JavaScript differs from most
languages in that it doesn’t report an error when a non-existant property is
accessed.
--
Dr. Axel Rauschmayer
[email protected]
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss