Underscore.js Collections: Invoke
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script>
<a target="parent" href="http://underscorejs.org/#invoke">Learn More</a>
JavaScript
var arr = [[5,4,3],[3,7,88],[99,66,48]];
var arr2 = "66635435345";
//Sort
var testInvoke = _.invoke(arr, 'sort');
//console.log(testInvoke[0],testInvoke[1],testInvoke[2]);
//[3, 4, 5] [3, 7, 88] [48, 66, 99]
//Slice
var testInvoke = _.invoke(arr, console.error, [{reset: true}]);
function testFunc (fg) {
console.log(fg);
}
//console.log(testInvoke);
//["6", "6", "6", "3", "5", "4", "3", "5", "3", "4", "5"]