Edit in JSFiddle

var myArray = (function() {
    var a = [],
        l = 10000;
    while (l--) {
        a.push("foo#" + l);
    }
    return a;
}());
document.getElementById('foo').onclick = go;

function go() {
    var cont = document.getElementById('cont'),
        elem = document.createElement('div');

    function handler(element, index) {
        var el = elem.cloneNode(true);
        el.appendChild(document.createTextNode(element));
        cont.appendChild(el);
    }

    function _each(arr, fn /*function(element, index)*/ , limit /*items per pass*/ , callback) {
        var count = 0,
            len = arr.length;

        function run() {
            var d = limit;
            while (d-- && len >= count) {
                fn(arr[count], count++);
            }
            if (len > count) {
                setTimeout(run, 1);
            } else {
                if (typeof callback === "function") {
                    callback();
                }
            }
        }
        run();
    }

    var start = new Date().getTime();
    _each(myArray, handler, 10, function() {
        alert('completed in ' + (new Date().getTime() - start) + "ms");
    });
}