Joined November 2018
·

Andrew Houser

Senior Software Engineer at QLess
·
Portsmouth, NH
·
·
·

This is a really nice and compact solution, however I found it didn't work with objects. I have a version that does take into account objects and mixed value arrays:

var j = {};

this.forEach(function (v) {
  var typ = (typeof v === 'object') ? 'object' : typeof v;
  var v = (typ === 'object') ? JSON.stringify(v) : v;

  j[v + '::' + typ] = v;
});

return Object.keys(j).map(function (v) {
  if (v.indexOf('::object') > -1) {
    return JSON.parse(j[v]);
  }

  return j[v];
});
Achievements
1 Karma
0 Total ProTip Views
Interests & Skills