lodash

 https://lodash.com/docs/4.17.15#pullAllBy

Object.fromEntries

Exemples

const cours = { html: 12, css: 2, JS: 30 };

Object.entries(cours)

> Array [Array ["html", 12], Array ["css", 2], Array ["JS", 30]]

Object.fromEntries(Object.entries(cours))

> Object { html: 12, css: 2, JS: 30 }


En action

const cours = { html: 12, css: 2, JS: 30 };
const  choix = Object.fromEntries(
  Object.entries(cours)
  .filter(([ _, val ]) => val>10 )
);
console.log(choix); // > Object { html: 12, JS: 30 }

En action

const words = ["Beau", "cool", "Ange", "Ananas", "ballon"]; const alpha = words.reduce((a, x) => { const l = x[0].toUpperCase() if(!a[l]) a[l] = []; a[l].push(x); return a; }, {}); const glosaire = Object.fromEntries( Object.entries(alpha) .sort(([a] , [b]) => a<b?-1:1)); console.log(glosaire); //
  • [object Object] {
      A
    : ["Ange", "Ananas"],
      B
    : ["Beau", "ballon"],
      C
    : ["cool"]
    }

regexp

 function normalizeDataKey(key) {

    return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`);
  }

  console.log(normalizeDataKey("denisDupont")) // denis-dupont

destructuration, map

const arr = [{

    id: 1,
    name: 'bill'
  }, {
    id: 2,
    name: 'ted'
  }]
  
const result = arr.map( ({id:value,name:text}) => ({ value, text }));
  console.log(result)