, ( lodash):
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function shuffleObject(obj) {
var keys = this.shuffle(_.keys(obj));
var newObj = {};
keys.forEach(function(elm, index){
newObj[elm] = obj[elm];
if(index === keys.length-1){
return newObj;
}
})
}
console.log(shuffleObject({ "A": 1, "B": 2, "C": 3, "D": 4 });