Victor Kimura
asked on
Javascript: optimize loops
Hi,
I was just reading these posts:
http://jonraasch.com/blog/10-javascript-performance-boosting-tips-from-nicholas-zakas
http://www.nczonline.net/blog/2009/01/13/speed-up-your-javascript-part-1/
In particular, my question alludes to the second post from nczonline.net. Supposedly, this function that Zakas, the author created will give a boost in performance in loops:
Two questions:
1) I'm wondering they there is a timer set to 100ms. Doesn't that slow down the execution?
2) What is the arguments.callee? What object is the arguments from?
Much thanks.
I was just reading these posts:
http://jonraasch.com/blog/10-javascript-performance-boosting-tips-from-nicholas-zakas
http://www.nczonline.net/blog/2009/01/13/speed-up-your-javascript-part-1/
In particular, my question alludes to the second post from nczonline.net. Supposedly, this function that Zakas, the author created will give a boost in performance in loops:
function chunk(array, process, context){
setTimeout(function(){
var item = array.shift();
process.call(context, item);
if (array.length > 0){
setTimeout(arguments.callee, 100);
}
}, 100);
}
Two questions:
1) I'm wondering they there is a timer set to 100ms. Doesn't that slow down the execution?
2) What is the arguments.callee? What object is the arguments from?
Much thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I get it. Thank you so much for the clear and thorough answers, Alex! =)
I highly recommend the following book:
High Performance Javascript
Shortly my website will be online and you'll have a lot of resources on this subject also.
Cheers!
High Performance Javascript
Shortly my website will be online and you'll have a lot of resources on this subject also.
Cheers!
ASKER
That's great, Alex. I'm looking forward to your site and updates on them. Keep me posted on your site. =)
ASKER
Just wondering now regarding the second question:
2) What is the arguments.callee? What object is the arguments from?