+ 1

Which is default example in loop i++ or ++i?

for(var i = 0; i < 10; i++) for(var i = 0; i < 10; ++i)

19th May 2019, 12:00 PM
Ilia Sichinava
Ilia Sichinava - avatar
3 Antworten
+ 11
Both are equivalent for what you have written.
20th May 2019, 3:06 AM
Sonic
Sonic - avatar
+ 8
In real life, it doesn't make any difference whatsoever. I've seen professional coders using either of them In theory, ++i might be a little more efficient since no temporary variable is needed. But I can't guarantee that this is even correct and if there's really a difference it's probably so small that it might not even be measurable
19th May 2019, 12:31 PM
Anna
Anna - avatar
+ 2
for(var i = 0; i < 10; i++)
19th May 2019, 12:14 PM
Solo
Solo - avatar