I have a global array containing the IDs of elements that I am currently working with. Every second I run a routine that does stuff to these elements.
var ids = ['abc', 'def', 'zyx']
// the following code happens every second
for (var i = 0; i < ids.length; i++) {
el = $("#" + ids[i])
// do stuff with el
}
My question: would I suffer a notable performance hit or improvement to do the following:
var ids = []
ids.push($("#abc"))
ids.push($("#def"))
ids.push($("#zyx"))
for (var i = 0; i < ids.length; i++) {
el = ids[i]
// do stuff with el
}