I don’t think I realized that for each can be used for normal Objects in 
ActionScript. I always assumed it was restricted to array-like objects to loop 
through the indexed values.

Like I mentioned in the JIRA here: 
https://issues.apache.org/jira/browse/FLEX-35070 that for-in is not a good 
replacement for cases where Array has custom properties or methods added to it 
(which happens in Javascript).

On Apr 25, 2016, at 6:22 PM, Josh Tynjala <joshtynj...@gmail.com> wrote:

> for-each loops are commonly used with string keys too, so I'm guessing
> that's why the code gets converted to a for-in loop. That would be fully
> compatible with both integer and string keys. I guess if the target is an
> Array or Vector, it would be possible to use a for(;;) loop instead. It
> could still potentially break on edge cases, though.
> 
> - Josh
> 
> On Mon, Apr 25, 2016 at 12:37 AM, lizhi <s...@qq.com> wrote:
> 
>> i do not konw the best code,but this code fast than now
>> 
>> //slow code
>> var foreachiter0_target = this.ss;
>>  for (var foreachiter0 in foreachiter0_target)
>>  {
>>  var s = foreachiter0_target[foreachiter0];
>>  {
>>  }}
>> 
>> //more fast code
>>  var len=this.ss.length;
>>  for(var i=0;i<len;i++){
>>          var s = this.ss[i];
>>  }
>> 
>> 
>> 
>> --
>> View this message in context:
>> http://apache-flex-development.2333347.n4.nabble.com/flexjs-foreach-very-slow-tp52571.html
>> Sent from the Apache Flex Development mailing list archive at Nabble.com.
>> 

Reply via email to