+ 1
Which is default example in loop i++ or ++i?
for(var i = 0; i < 10; i++) for(var i = 0; i < 10; ++i)
3 Antworten
+ 11
Both are equivalent for what you have written.
+ 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
+ 2
for(var i = 0; i < 10; i++)