SO Answer / merge two arrays of keys and values to an object using underscore

See: http://stackoverflow.com/questions/12199051/merge-two-arrays-of-keys-and-values-to-an-object-using-underscore

by KooiInc MeHere

HTML

<script src="https://kooiinc.github.io/JSHelpers/Helpers-min.js"></script>
<div class="solink" data-linkid="12199051"></div>
<pre id="result"></pre>

JavaScript

(function() {
    Object.print = objPrint;
    Object.concat = objConcat;
    extendArr();
    
    var keys         = ['foo', 'bar', 'qux'];
    var values       = ['1', '2', '3'];
    var weekdays     = 'sun,mon,tue,wed,thu,fri,sat'.split(',');
    var log          = Helpers.log2Screen;
    var weekobj      = weekdays.toObj([0,1,2,3,4,5,6]);
    var otherweekobj = [0,1,2,3,4,5,6].toObj(weekdays);
    var weekEnum     = toEnum(weekdays, [0,1,2,3,4,5,6])
    var some         = {};
    var other        = {};
    var _object      = _.object(keys, values);
    var yetAnother   = ['foo', 'bar', 'qux'].toObj([1,2,3]);
    
    _.each(keys,function(k,i){some[k] = values[i];});
    
    log('<b>Using _ (underscore) methods</b>\n');
    
    log( '`_.each(keys,function(k,i){some[k] = values[i];})`\n`some` now:\n',
         Object.print(some) );
    
    //alternatively create the object in one go:
    _.zip(['foo', 'bar', 'qux'],['FOOval', 'BARval', 'QUXval'])
      .map(function(v){this[v[0]]=v[1];}, other);
    
    log( "`_.zip(['foo', 'bar', 'qux'], ['FOOval', 'BARval', 'QUXval'])\n",
         "    .map(function(v){this[v[0]]=v[1];}, other)`\n`other` now:\n",
         Object.print(other) );
    
    log( "`_object = _.object(keys, values)`\n`_object` now: ",
         Object.print(_object) );

    log( "\n<b>Using Array Extension</b>\n",
         "`yetAnother = ['foo', 'bar', 'qux'].toObj([1,2,3])`",
          "\n`yetAnother` now:\n", 
          Object.print(yetAnother) );
    
    log( '`weekojb = weekdays.toObj([0,1,2,3,4,5,6])`\n`weekobj` now:\n', 
         Object.print(weekobj), '\n',
         '`otherweekobj = [0,1,2,3,4,5,6].toObj(weekdays)`\n`otherweekobj` now:\n',
         Object.print(otherweekobj) );
    
    log( "`weekEnum = toEnum(weekdays, [0,1,2,3,4,5,6])`\n`weekEnum` now: ",
         Object.print(weekEnum) );
    
    function toEnum(keys, values) {
        return Object.concat(keys.toObj(values), values.toObj(keys));
    }
    
    function...