Last active
August 29, 2015 14:21
-
-
Save rs77/37eae99da0f600aeb588 to your computer and use it in GitHub Desktop.
This function is handy when working with Google App Script for Spreadsheets and you need to get an array out of the 2-dimensional getValues() call. In fact, you may want to look at this performance test and see that running indexOf on array data may be quite slow in comparison to their for-loop and while-loop counterparts as seen here: http://js…
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 findElem( el ) { | |
return !!~el.indexOf( this.val ); | |
} | |
// for example: | |
var arr = [ [ 18, "AAA" ], [ 19, "BBB" ], [ 20, "CCC" ] ]; | |
var query = 19; | |
console.log( arr.filter( findElem, { val: query } ) ); // returns [[19, "BBB"]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment