faqts : Computers : Programming : Languages : JavaScript : XML : E4X (ECMAScript for XML) : XML objects

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

How do I use the method propertyIsEnumerable?
How do I use the method propertyIsEnumerable?

Apr 12th, 2005 00:51
Martin Honnen,


The method propertyIsEnumerable takes one argument, a property name. The
argument is converted to a string and the method returns true if the
property name is '0' and false otherwise. This is done to intentionally
blur the distinction between an XML object and an XMLList containing one
object.
Here are some examples:
  var gods = <gods>
    <god>Kibo</god>
    <god>Xibo</god>
  </gods>;
  alert(gods.propertyIsEnumerable('0')); // shows 'true'
  alert(gods.propertyIsEnumerable('1')); // shows 'false'
  for (var propertyName in gods) {
    alert(propertyName);
  }
  // shows '0'