Yeah, as your examples show, the cost of not caching array length is almost always neglible. Developers should just use common sense and cache the length for massive arrays only - knee-jerk micro-optimization strategies are often the enemy of readability
BTW forEach carries its own performance issues (potentially more serious) with large arrays since every iteration is a function call -- 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]
