Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Merger Douplicate array

var array = [{name:"foo1",value:"val1"},{name:"foo1",value:["val2","val3"]},{name:"foo2",value:"val4"}];

function mergeNames (arr) {
    return _.chain(arr).groupBy('name').mapValues(function (v) {
        return _.chain(v).pluck('value').flattenDeep();
    }).value();
}

console.log(mergeNames(array));
Comment

PREVIOUS NEXT
Code Example
Javascript :: wait in js 
Javascript :: lesson-3 
Javascript :: initial min js 
Javascript :: javascript select element with pointer 
Javascript :: js event problem solving 
Javascript :: asp.net run javascript on page load 
Javascript :: Play css animation with JS onhover 
Javascript :: jquery to vanilla js converter 
Javascript :: Decodes a string of data which has been encoded using base-64 encoding - Nodejs 
Javascript :: react native run on a particular emu 
Javascript :: https://discord.com/api/guilds/845154482256871435/widget.json 
Javascript :: firestore return the content of an aarray Nodejs 
Javascript :: cdate ssrs expressions 
Javascript :: amelia earheart 
Javascript :: if raro 
Javascript :: javscript explode by backticks 
Javascript :: change color of input if submit clicked and input is empty 
Javascript :: discord.js slash commend 
Javascript :: petrov attack 
Javascript :: $("#heading").offset({ left: left Offset }); 
Javascript :: exit forEach when null javascript 
Javascript :: How to update Code Mirror data on modal show 
Javascript :: jequery mose up 
Javascript :: how to convert serilazed data to json in js 
Javascript :: js check if tab switched 
Javascript :: javascript fix errora 
Javascript :: js create element with attributes 
Javascript :: queen of spain 
Javascript :: how do i count the number of occurrences in a string javascript 
Javascript :: change span value according to textfierld value in jquery 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =