Enterprise APP

The "in" operator 본문

Flex General/Tips

The "in" operator

로드스타 2010. 5. 26. 06:28

Juten Tach,

i work with Actionscript for some time now, but i wasn’t aware of that little thing. You can use “in” for checking, if an attribute/field exists in an object, like so:

package {
   import flash.display.Sprite;

   public class Test extends Sprite {

      public function Test() {
         var myObject:Object = {name: "foo", nothing: "bar"};
         trace("name" in myObject);     // true
         trace("anything" in myObject); // false
      }
   }
}
Comments