Skip to content

Instantly share code, notes, and snippets.

@DavidBruant
Last active December 21, 2015 05:28
Show Gist options
  • Save DavidBruant/6256883 to your computer and use it in GitHub Desktop.
Save DavidBruant/6256883 to your computer and use it in GitHub Desktop.
Unique strings/symbols practicality
(function(global){
var findIndexPropName = String.unique();
var shufflePropName = String.unique();
Array.prototype[findIndexPropName] = function(){ /*...*/ };
Array.prototype[shufflePropName] = function(){ /*...*/ };
global.arraySupplementals = {
findIndex: findIndexPropName,
shuffle: shufflePropName
};
})(this)
(function(global){
var {findIndex, shuffle} = global.arraySupplementals;
var myArray = [/*...*/];
function f(){ /*...*/ }
console.log(myArray[findIndex](f)
myArray[shuffle]();
console.log(myArray[findIndex](f))
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment