How to use the rest function from lodash

Find comprehensive JavaScript lodash.rest code examples handpicked from public code repositorys.

5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
*  style callback, respectively.
* @param {*} [thisArg] The `this` binding of `callback`.
* @returns {Array} Returns a slice of `array`.
* @example
*
* _.rest([1, 2, 3]);
* // => [2, 3]
*
* _.rest([1, 2, 3], 2);
* // => [3]
fork icon73
star icon711
watch icon29

+ 7 other calls in file

324
325
326
327
328
329
330
331
332
333
module.exports.remove              = _.remove;
module.exports.renameKeys          = _.renameKeys;
module.exports.repeat              = _.repeat;
module.exports.repeatContrib       = _.repeatContrib;
module.exports.replace             = _.replace;
module.exports.rest                = _.rest;
module.exports.result              = _.result;
module.exports.reverse             = _.reverse;
module.exports.reverseOrder        = _.reverseOrder;
module.exports.round               = _.round;
fork icon19
star icon122
watch icon0

+ 92 other calls in file

2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
// ### Fixed arguments

// Fixes the arguments to a function based on the parameter template defined by
// the presence of values and the `_` placeholder.
fix: function(fun) {
  var fixArgs = _.rest(arguments);

  var f = function() {
    var args = fixArgs.slice();
    var arg = 0;
fork icon3
star icon2
watch icon1

+ 589 other calls in file

344
345
346
347
348
349
350
351
352
353
354
355
356
console.log(partialRight(3)); // => 6


const rearg = _.rearg((a, b, c) => [a, b, c], [2, 0, 1]);
console.log(rearg(1, 2, 3)); // => [3, 1, 2]


const rest = _.rest((a, b, ...c) => [a, b, c]);
console.log(rest(1, 2, 3, 4)); // => [1, 2, [3, 4]]


const spread = _.spread((a, b, c) => a + b + c);
console.log(spread([1, 2, 3])); // => 6
fork icon0
star icon4
watch icon0

+ 15 other calls in file

227
228
229
230
231
232
233
234
235
236
237
let rearged1 = rearged('b', 'c', 'a');
console.log('rearged1--->', rearged1);
//rearged1---> [ 'a', 'b', 'c' ]


//_.rest(func,[start=func.length-1])
var say = _.rest(function (what, names) {
    return what + ' ' + _.initial(names).join(', ') +
        (_.size(names) > 1 ? ', & ' : '') + _.last(names);
});

fork icon0
star icon0
watch icon0

+ 3 other calls in file

Other functions in lodash

Sorted by popularity

function icon

lodash.get is the most popular function in lodash (7670 examples)