_.sample

sample_.sample(list, [n]) Produce a random sample from the list. Pass a number to return n random elements from the list. Otherwise a single random item will be returned. _.sample([1, 2, 3, 4, 5, 6]); => 4 _.sample([1, 2, 3, 4, 5, 6], 3); => [1, 6, 2]

_.toArray

toArray_.toArray(list) Creates a real Array from the list (anything that can be iterated over). Useful for transmuting the arguments object. (function(){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); => [2, 3, 4]

_.defaults

defaults_.defaults(object, *defaults) Fill in undefined properties in object with the first value present in the following list of defaults objects. var iceCream = {flavor: "chocolate"}; _.defaults(iceCream, {flavor: "vanilla", sprinkles: "lots"}); => {flavor: "chocolate", sprinkles: "lots"}

_.intersection

intersection_.intersection(*arrays) Computes the list of values that are the intersection of all the arrays. Each value in the result is present in each of the arrays. _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); => [1, 2]

_.isError

isError_.isError(object) Returns true if object inherits from an Error. try { throw new TypeError("Example"); } catch (o_O) { _.isError(o_O); } => true

_.uniqueId

uniqueId_.uniqueId([prefix]) Generate a globally-unique id for client-side models or DOM elements that need one. If prefix is passed, the id will be appended to it. _.uniqueId('contact_'); => 'contact_104'

_.isArguments

isArguments_.isArguments(object) Returns true if object is an Arguments object. (function(){ return _.isArguments(arguments); })(1, 2, 3); => true _.isArguments([1,2,3]); => false

_.findWhere

findWhere_.findWhere(list, properties) Looks through the list and returns the first value that matches all of the key-value pairs listed in properties. If no match is found, or if list is empty, undefined will be returned. _.findWhere(publicServicePulitzers, {newsroom: "The New York Times"}); => {year: 1918, newsroom: "The New York Times", reason: "For its public service in publishing in full so many official reports, documents and speeches by European statesmen relating to the pro

_.allKeys

allKeys_.allKeys(object) Retrieve all the names of object's own and inherited properties. function Stooge(name) { this.name = name; } Stooge.prototype.silly = true; _.allKeys(new Stooge("Moe")); => ["name", "silly"]

_.findLastIndex

findLastIndex_.findLastIndex(array, predicate, [context]) Like _.findIndex but iterates the array in reverse, returning the index closest to the end where the predicate truth test passes. var users = [{'id': 1, 'name': 'Bob', 'last': 'Brown'}, {'id': 2, 'name': 'Ted', 'last': 'White'}, {'id': 3, 'name': 'Frank', 'last': 'James'}, {'id': 4, 'name': 'Ted', 'last': 'Jones'}]; _.findLastIndex(users, { name: 'Ted' }); => 3