Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Lodash-Array
  • Lodash-Collection
  • Lodash-Function
  • Lodash-Lang
  • Lodash-Math
  • Lodash-Object
  • Lodash-Sequence
  • Lodash-String
  • Lodash-Util
  • JavaScript
  • Web Technology
Open In App
Next Article:
Lodash _.prototype.commit() Method
Next article icon

Lodash _.prototype.chain() Method

Last Updated : 03 Nov, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Lodash _.prototype.chain() method of Sequence in lodash is used to create an instance of lodash wrapper accompanied by explicit method chain sequences enabled.

Syntax:

_.prototype.chain();

Parameters:

This method doesn't accept any parameter.

Return Value:

This method returns the new lodash wrapper instance.

Example 1: In this example, we are chaining the given array and getting the tail value by the use of the lodash _.prototype.chain() method.

JavaScript
// Requiring lodash library const _ = require('lodash');  // Initializing authors variable let authors = [     { 'author': 'Nidhi', 'articles': 750 },     { 'author': 'Nisha', 'articles': 500 } ];  // Calling chain() method and creating // an explicit chaining sequence let result = _(authors).chain()     .tail()     .value();  // Displays output                        console.log(result); 

Output:

[ { author: 'Nisha', articles: 500 } ]

Example 2: In this example, we are chaining the given array and getting the head value having article as a key by the use of the lodash _.prototype.chain() method.

JavaScript
// Requiring lodash library const _ = require('lodash');  // Initializing authors variable let authors = [     { 'author': 'Nidhi', 'articles': 750 },     { 'author': 'Nisha', 'articles': 500 } ];  // Calling chain() method and creating // an explicit chaining sequence let result = _(authors).chain()     .head()     .pick('articles')     .value();  // Displays output                        console.log(result); 

Output:

{ articles: 750 }

Example 3: In this example, we are chaining the given string by the use of the lodash _.prototype.chain() method.

JavaScript
// Requiring lodash library const _ = require('lodash');  // Calling chain() method and creating // an explicit chaining sequence let obj = _("GeeksforGeeks").chain().value();  // Displays output                        console.log(obj[0]); console.log(obj[4]); console.log(obj[7]); console.log(obj[11]); 

Output:

G s r k

Reference: https://lodash.com/docs/4.17.15#prototype-chain


Next Article
Lodash _.prototype.commit() Method

N

nidhi1352singh
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • JavaScript-Lodash

Similar Reads

    Lodash _.chain() Method
    Lodash _.chain() method is used to wrap the value with explicit method chain sequences enabled.  Syntax:_.chain(value);Parameter:value parameter holds the value to wrap.Return value: This method returns the wrapped value. Example 1: In this example, we have used the _.chain() method in which we have
    2 min read
    Lodash _.tap() Method
    Lodash _.tap() method of Sequence in lodash is used to call interceptor. Moreover, the main task of the method is to "tap into" a method chain sequence so that the intermediate results can be modified. Syntax:_.tap(value, interceptor);Parameters: value: It is the value to be given to the interceptor
    2 min read
    Lodash _.thru() Method
    Lodash _.thru() method of Sequence in lodash is similar to _.tap() method and the only difference is that it returns the outcome of the interceptor. Moreover, this method is mainly used to “pass thru” values in a method chain sequence by replacing intermediate results. Syntax:_.thru(value, intercept
    2 min read
    Lodash _.prototype[Symbol.iterator]() Method
    Lodash _.prototype[Symbol.iterator]() method of Sequence in lodash is used to permit the wrapper to be iterable. Syntax:_.prototype[Symbol.iterator]();Parameters: This method doesn't accept any parameter. Return Value: This method returns the lodash wrapper object. Example 1: In this example, we are
    1 min read
    Lodash _.prototype.at() Method
    Lodash _.prototype.at([paths]) method of Sequence in lodash is the wrapper version of the _.at() method which creates an array of values analogous to the specified paths of an object. Syntax:_.prototype.at([paths]);Parameters:[paths]: It is the paths property that is to be chosen.Return Value: This
    1 min read
    Lodash _.prototype.chain() Method
    Lodash _.prototype.chain() method of Sequence in lodash is used to create an instance of lodash wrapper accompanied by explicit method chain sequences enabled. Syntax:_.prototype.chain();Parameters: This method doesn't accept any parameter. Return Value: This method returns the new lodash wrapper in
    2 min read
    Lodash _.prototype.commit() Method
    Lodash _.prototype.commit() method is used to implement the chain sequence type and find the wrapped output. Syntax:_.prototype.commit();Parameters: This method does not accept any parameter. Return Value: This method returns the new lodash wrapper instance. Example 1: In this example, we are pushin
    2 min read
    Lodash _.prototype.next() Method
    Lodash _.prototype.next() method of Sequence in lodash is used to find the next value on a wrapped object which follows the iterator protocol. Syntax:_.prototype.next();Return Value: This method returns the value of the next iterator. Example 1: In this example, it returns the next value of the wrap
    2 min read
    Lodash _.prototype.plant() Method
    Lodash _.prototype.plant(value) method of Sequence in lodash is used to create a clone of the chain sequence type by planting the value to be planted as the wrapped value. Syntax:_.prototype.plant(value);Parameters: value: It is the value that needs to be planted.Return Value: This method returns th
    1 min read
    Lodash _.prototype.reverse() Method
    Lodash _.prototype.reverse() method of Sequence in lodash is used to mutate the wrapped array. Moreover, it is the wrapper version of the _.reverse method of an array. Syntax:_.prototype.reverse();Parameters: This method doesn't accept any parameter. Return Value: This method returns the new lodash
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences