Flex中的 for in 与 for each in

(1)for...in循环中的迭代变量是对象中的属性,键值对中的键值

var mockData:Object={ID: 1,Say:"Hello",Name:"yuxuanji"};

for (var entry:Object in mockData)
{
     trace(entry); 
}

console output:

ID
Say
Name

 

//结论:for 遍历的是key


(2)for each...in循环中的迭代变量是对象键值对中保存的值(属性所保存的值)

for each (var entry:Object in mockData)
{
trace(entry);

}

console output:

123
Hello

yuxuanji

//结论:for each遍历的是value