Convert array To Object - Node.js Array

Node.js examples for Array:Convert Array

Description

Convert array To Object

Demo Code



exports.arrayToObject = function (source) {

    var obj = {};
    for (var i = 0, il = source.length; i < il; ++i) {
        if (typeof source[i] !== 'undefined') {

            obj[i] = source[i];/*from   w  w w  .j  a v a2  s .c  o  m*/
        }
    }

    return obj;
};

Related Tutorials