_.invoke(object, path, [args])

sourcenpm package

Invokes the method at path of object.

Since

4.0.0

Arguments

  • object (Object): The object to query.
  • path (Array|string): The path of the method to invoke.
  • [args] (…*): The arguments to invoke the method with.

Returns

(*): Returns the result of the invoked method.

Example

  1. var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
    _.invoke(object, 'a[0].b.c.slice', 1, 3);
    // => [2, 3]