Dev HelpersOpen library
← Back

Group into a prototype-free object

Group into a prototype-free object in JavaScript.

Open this example in the interactive library

Source code

const labels = Object.groupBy(
  ["constructor", "draft", "constructor"],
  (key) => key,
);
console.log(Object.getPrototypeOf(labels) === null, labels.constructor);

Sample output

true [ 'constructor', 'constructor' ]