Loading ...
Sorry, an error occurred while loading the content.

2095infix_in warnings

Expand Messages
  • John Hawkinson
    Apr 1, 2011
      In late Feb, Douglas added this warning:

      infix_in: "Unexpected 'in'. Compare with undefined, or use the
      hasOwnProperty method instead.",

      This causes problems for me in Adobe's ExtendScript JavaScript
      implementation[*], where some kind of DOM objects do not return
      'undefined' for undefined properties, but instead throw errors.
      (These are typically objects that are backed by C++ implementations
      in the relevant Adobe application).

      So where I would like to check:

      if (image.effectivePpi && image.effectivePpi[0] < threshold)

      I cannot. My first reaction is to use

      if ('effectivePpi' in image && image.efffectivePpi < threhsold)

      but that triggers the infix_in warning.
      I am loathe to use

      if (image.hasOwnProperty('effectivePpi') &&
      image.effectivePpi < threshold)

      because I don't know that the effectivePpi property might not be inherited,
      and I do not wish to disregard the inheritance chain.

      It does not appear that /*jslint forin: true */ is sufficient to
      permit this usage.

      Is there a better recommendation?

      I think I have lost track of why the infix form of in is prohibitted;
      I understand why the prefix form should be filtered, but not why the
      infix form is barred.


      John Hawkinson

      [*] in particular, this is

      "The ExtendScript scripting engine
      Copyright 1998-2010 Adobe Sytems Incoporated
      Version 4.12.2
      Build version 64.447932
      Build date 2010/11/15-23:35:46
      ScriptUI version 5.1.37"
    • Show all 6 messages in this topic