Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » "Convert for loops to enhanced" in JavaScript
"Convert for loops to enhanced" in JavaScript [message #219363] Mon, 18 August 2008 10:21 Go to previous message
Eclipse User
Originally posted by: bleper.google.com

Hello folks,

I've noticed something really weird in Eclipse Ganymede regarding
JavaScript. Quick look through the new options, and I've discovered
something like this: JavaScript > Code Style > Clean Up > [edit any
profile] > Code Style > Control statements > Convert for loops to enhanced.

The code snippet on right shows such an "optimization":

for (var i = 0; i < ids.length; i++) {
var value= ids[i] / 2;
alert(value);
}

becomes

for (var element in ids) {
var value= element / 2;
alert(value);
}

WTF? This is not only vary bad practice; it won't work in the first place!

For those equally horrified as me: yes, I tried to apply this automatic
"fix" to my code, and fortunately it didn't do anything. ;-)

BL
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:WTP 3.0 and Maven2 for J2EE/JEE?
Next Topic:Re: Cannot create a session bean with Eclipse 3.4.0
Goto Forum:
  


Current Time: Thu May 23 03:47:14 EDT 2013

Powered by FUDForum. Page generated in 0.01683 seconds