Last active
December 21, 2015 05:28
-
-
Save DavidBruant/6256883 to your computer and use it in GitHub Desktop.
Unique strings/symbols practicality
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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