Yet another inane question...but I am looking for coding "best practices" here.
I have always used i++ to increment vars, but have recently found that some well-respected JS coders such as Douglas Crawford use a different method i += 1.
When incrementing by a single integer (1), is the += method still preferred? I can see if you wanted to increment by a value greater than 1 (i.e. i += 2, 3, ... infinity), but otherwise, what is the benefit? Are there situations where i++ can fail or cause problems?
Thanks.
I have always used i++ to increment vars, but have recently found that some well-respected JS coders such as Douglas Crawford use a different method i += 1.
When incrementing by a single integer (1), is the += method still preferred? I can see if you wanted to increment by a value greater than 1 (i.e. i += 2, 3, ... infinity), but otherwise, what is the benefit? Are there situations where i++ can fail or cause problems?
Thanks.
Comment