Skip to content

Instantly share code, notes, and snippets.

View joemarchese's full-sized avatar

Joseph Marchese joemarchese

  • Williamsport, PA
View GitHub Profile
@brettz9
brettz9 / set.js
Last active December 10, 2019 23:18
Simple JS equivalent of the Python set() constructor (without the methods)
/**
* Simple JS equivalent of the Python set() constructor (without the methods)
* @requires shim: Array.prototype.indexOf
* @param {array} arr The array to turn into a set
* @example
* var mySet = set(['red', 'yellow', 'black', 'yellow']);
* mySet.length; // 3
* JSON.stringify(mySet); // ["red","yellow","black"]
* @see For a fuller version, see {@link https://npmjs.org/package/set}
*/