Skip to content

Instantly share code, notes, and snippets.

@DavidBruant DavidBruant/_library.js
Last active Dec 21, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.