>>Note I also use ++i over i++ because it's slightly faster on some modern
browsers.
I read the same thing on Andrea Giammarchi's site but I don't think its
true. Check the ECMA 5 standard. Since a for loop does not use the return
value of i++ or ++i the only interesting part is steps 4 and 5 for each case
- and they are identical.
11.3.1 Postfix Increment Operator The production *PostfixExpression** : **
LeftHandSideExpression* *[no *LineTerminator* here] ++* is evaluated as
follows:
1. Let *lhs* be the result of evaluating *LeftHandSideExpression*.
2. Throw a *SyntaxError* exception if the following conditions are all
true:
- Type(*lhs*) is Reference is *true*
- IsStrictReference(*lhs*) is *true*
- Type(GetBase(*lhs*)) is Enviroment Record
- GetReferencedName(*lhs*) is either "eval" or "arguments"
3. Let *oldValue* be ToNumber(GetValue(*lhs*)).
4. Let *newValue* be the result of adding the value 1 to *oldValue*,
using the same rules as for the + operator (see
11.6.3<http://ecma262-5.com/ELS5_HTML.htm#Section_11.6.3>
).
5. Call PutValue(*lhs*, *newValue*).
6. Return *oldValue*.
11.4.4 Prefix Increment Operator ( *++* ) The production *UnaryExpression*
* : ++* *UnaryExpression* is evaluated as follows:
1. Let *expr* be the result of evaluating *UnaryExpression*.
2. Throw a *SyntaxError* exception if the following conditions are all
true:
- Type(*expr*) is Reference is *true*
- IsStrictReference(*expr*) is *true*
- Type(GetBase(*expr*)) is Enviroment Record
- GetReferencedName(*expr*) is either "eval" or "arguments"
3. Let oldValue be ToNumber(GetValue(*expr*)).
4. Let newValue be the result of adding the value 1 to *oldValue*, using
the same rules as for the + operator (see
11.6.3<http://ecma262-5.com/ELS5_HTML.htm#Section_11.6.3>
).
5. Call PutValue(*expr*, *newValue*).
6. Return .
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]