[jQuery] Optimized Function to transfer Array to Listbox
I have two array of items containing the values and text to be
inserted in a Listbox. I had written the function as:
array2Listbox = function(objListBox, arrValue, arrText) {
var oNewOption;
return jQuery.each(arrValue, function(i) {
oNewOption = new Option(arrText[i], arrValue[i]);
objListBox[objListBox.length] = oNewOption;
});
};
However I know jQuery would be much slower than direct for loop in
this case where the array size is approx 6000 elements. Can anyone
tell me a faster way to loop through the array and insert the elements
in Listbox.