Reputation: 11
I am learning Javascript from CrockFord video "Crockford on javascript" and I am watching : "Function The Ultimate" In one of his code "he was talking about " pseudo parameters" " I saw something like this :
for( i = 0; i<n; i+=1)
So why he is not using the increment operator "++" and he is using the "+=", i know they do the same but is there a performance difference ?
Thank you.
Upvotes: 1
Views: 103
Reputation: 108410
There's no measurable performance difference. You'd be hard pressed to write a test case in which you could measure any difference.
As Ronnie pointed out in his comment, the ++
operator increments by 1, but the +=
can add an amount other than 1.
Upvotes: 1
Reputation: 4175
As the OP is talking about performance, I set up a JSPerf to see how the two compare. Go ahead and test this out for yourself:
http://jsperf.com/inc-vs-plus-one
Upvotes: 3