[Laszlo-dev] [JIRA] Commented: (LPP-6670) Remove `if (a in b)` when a is an instance var in b's class

Philip Romanik promanik at laszlosystems.com
Thu Jul 24 07:37:47 PDT 2008


Many of the issues I have seen will be fixed with casting (ie: 'is' 
test followed by 'cast')


>My quick cut at what to do:
>
>In places where it is just checking for existence, `a in b` can be 
>rewritten `b['a']`.  If you are just going to use `null` instead of 
>`undefined` then say `b['a'] || null`.  If you are making an 
>`instanceof` check, change that to `is` because `instanceof` will 
>complain if its left arg is not an object, so `b['a'] is ...`.
>
>Couple of specific examples:
>
> > debugger/LzDebug.lzs
> >  if (! (('backtrace' in error) && (error.backtrace instanceof
> > LzBacktrace))) {
>error['backtrace'] is LzBacktrace
> >  var alen = (('length' in obj) &&
>probably (! isNaN(obj['length']))
> >  var hopp = 'hasOwnProperty' in obj && obj.hasOwnProperty instanceof
> > Function;
>obj['hasOwnProperty'] is Function
>
>Or, leave the debugger to me.  I don't think any of the debugger is in
>swf9 yet anyways.



More information about the Laszlo-dev mailing list