Lodash – takeRightWhile method

  • Post author:
  • Post category:Lodash
  • Post comments:2 Comments
Lodash - takeRightWhile method

Syntax Of Lodash takeRightWhile method

_.takeRightWhile(array, [predicate=_.identity])

Lodash takeRightWhile method creates a slice of array with elements taken from the end. Elements are taken until predicate returns falsey.

Arguments

  • array (Array) − The array to query.
  • [predicate=_.identity] (Function) − The function invoked per iteration.

Output

  • (Array) − Returns the slice of array.

Example

var _ = require('lodash');
var users = [
   { 'user': 'Mark',   'active': false },
   { 'user': 'Joe',     'active': true },
   { 'user': 'Jake', 'active': false }
];
 
var result = _.takeRightWhile(users, function(o) { return !o.active; });
console.log(result);

Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

Output

[ { user: 'Jake', active: false } ]

Next Topic – Click Here

This Post Has 2 Comments

Leave a Reply