how cakephp functions like Set::combine in Javascript

 

Questions


Are there already some javascript functions that do the same as the cakephp functions Set::combine and Set::classicExtract on client side in the browser?
http://book.cakephp.org/2.0/en/core-utility-libraries/set.html

So that I can bring this array:

a = [
   {
        'User' : {
            'id' : 2,
            'group_id' : 1,
            'name' : 'Alfred'
         }
    },
    {
        'User' : {
            'id' : 12,
            'group_id' : 2,
            'name' : 'Albert'
         }
    }
]

with a function like

Set::combine(a, '{n}.User.id', '{n}.User.name') 

into the format

a = {
  2 : 'Alfred',
  12 : 'Albert' 
}

for example. But it’s not only for this simple example, I’m really looking for a library or something which can do it in a similar way to cakephp.
Thanks a lot in advance!

 

 

————————————————-

Answer

cakephp,javascript,set

Facebook Comments

Post a comment