Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

OTHER CHANGES

To work seamlessly with standard ECMAScript, E4X makes some changes to the base language. One change is the introduction of the for-each-in loop. As opposed to the for-in loop, which iterates over each property and returns the property name, the for-each-in loop iterates over each property and returns the value of the property, as this example illustrates:

image
var employees =  <employees>
                    <employee position="Software Engineer">
                        <name>Nicholas C. Zakas</name>
                    </employee>
                    <employee position="Salesperson">
                        <name>Jim Smith</name>
                    </employee>
                </employees>;
                
for each (var child in employees){
    alert(child.toXMLString());
}

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial