>
Always count large arrays before iterations
Welcome, Guest

by Subhash on Thursday, 17 September 2009
Always count large arrays before iterations


0k. This is not particular to javascript but applies to all languages. Consider an array of 10,000 items.
Normally, a for loop will go like following:

var largeArray; // // this array has 10,000 items

for( var i=0; i < largeArray.length; i++)

{

//do something

}

In above case javascript has to calculate length of array in each  iteration and then check the 
termination condition. It will be far more efficient if we calculate length of array before loop, 
store it in a local variable and use this local variable for comparison. 
var largeArray; // this array has 10,000 items
var l = largeArray.length;
for( var i=0; i < l; i++)
{
//do something
}
This will save javascript from calculating the array length in each iteration and will be faster. 
 
 Thanks...

 



Blogger Image
My Blog Title

Product Engineering, software engineering company, Product Development, Product Migration, Product Re-engineering, Product Maintenance, Product Testing Commercial Application Development, Business Software development, commercial software for startups, Application Support and Maintenance, software testing Product Maintenance, Outsource product maintenance, product support and maintenance Product Migration, Product Re-engineering, product re-engineering services Product Research, Product Engineering, UI Prototyping Services Software Testing Services, Quality Assurance services, professional software testers, Load Testing, Functional Testing, Cross Platform, Browser Testing, Test Automation, Testing Tools, software quality analysis Functional Testing Services, software quality analysis, Software Testing Services, Application Testing Services, Functional Testing Types Automated Testing, Automated Testing Services, automation testing, test script development, Automation Test Tools, outsource automation testing Load Testing, Performance Testing Services, Load Testing Tools Offshore Software Development, Outsource software services, offshore outsourcing services, offshore software development services, IT outsourcing services, software quality assurance services, Offshore IT services, Custom Application Development Services, Offshore Product Engineering Benefits of IT Outsourcing, Offshore Software Development companies, offshore software development firms Outsource planning, IT outsourcing, IT development services, offshore IT companies, offshore software development Offshore Software Development, Outsource software services, offshore outsourcing services, offshore software development services, IT outsourcing services, software quality assurance services, Offshore IT services, Custom Application Development Services, Offshore Product Engineering Offshore Software Development, Outsource software services, offshore outsourcing services, offshore software development services, IT outsourcing services, software quality assurance services, Offshore IT services, Custom Application Development Services, Offshore Product Engineering