w10schools
Login Register
  • Home
  • Tutorials
    • HTML, CSS
      • HTML, HTML5
      • CSS, CSS3
    • XML
    • JavaScript, AJAX
    • PHP
    • Ruby on Rails
      • Ruby
      • Rails
    • ASP.NET
      • ASP
      • C# .NET
    • Java
      • JSP
    • Databases
      • MySQL
      • MSSQL Server
      • Oracle
    • Web Server
      • Windows
      • Linux
      • Apache
      • IIS
    • Design
      • Dreamweaver
      • Flash
      • Photoshop
      • Fireworks
      • CorelDRAW
      • Illustrator
  • References
    • HTML
      • Bootstrap
    • CSS
      • CSS Selectors
      • Sass
    • JavaScript
    • Mobile Apps
      • Cordova
    • Ruby on Rails
      • Ruby
      • Rails
    • PHP
      • Function
      • Language
      • CodeIgniter
      • Phalcon
      • PHPUnit
      • Symfony
      • Drupal
      • Yii
      • Laravel
    • Perl
      • Perl
    • Python
      • Python
      • Django
      • NumPy
      • Pandas
      • scikit-image
      • scikit-learn
      • Statsmodels
      • Matplotlib
    • Lua
      • Lua
    • C, C++
      • C
      • C++
    • Server
      • Docker
      • Apache HTTP Server
      • Nginx
    • Database
      • PostgreSQL
    • Big Data
      • TensorFlow
    • Game Development
      • Phaser
      • LÖVE
  • Articles
    • News
    • General
      • Website Promotion
      • Online Advertising
      • Make Money Online
    • Editorials
    • Interviews
    • Web Roundups
  • Resources
    • Design
      • Fonts
      • Graphics
      • Vectors
      • Templates
      • UI (User Interface)
      • Brushes
      • Patterns, Backgrounds
      • Textures
    • Web Development
      • HTML, CSS
      • XML
      • JavaScript, AJAX
      • Ruby on Rails
      • PHP
      • Java
      • .NET
      • Python
      • Perl
      • Flash
    • Mobile Application Development
      • Mobile Development Tools
      • Swift
    • Online Services
      • Online Storage
      • Web Hosting
  • Tools
    • Generators
Edit
In Place Editing Advanced Editing
  • References
  • JavaScript
  • Lodash
  • Array

_.nth

_.nth(array, [n=0])

source npm package

Gets the element at index n of array. If n is negative, the nth element from the end is returned.

Since

4.11.0

Arguments

  1. array (Array): The array to query.
  2. [n=0] (number): The index of the element to return.

Returns

(*): Returns the nth element of array.

Example

var array = ['a', 'b', 'c', 'd'];
 
_.nth(array, 1);
// => 'b'
 
_.nth(array, -2);
// => 'c';
Links:
  • https://lodash.com/docs/4.17.2#nth
doc_Lodash
doc_Lodash
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.

Popular Articles
nth nth($list, $n) Gets the nth item in a list. Note that unlike some languages, the first item in a Sass list is number 1, the second number 2, and so
GroupBy.nth() GroupBy.nth(n, dropna=None) [source] Take the nth row from each group if n is an int, or a subset of rows if n is a list of ints. If dropna, will
nth_child nth_child(a, b, of_type, reverse) Instance Protected methods Returns a lambda that can match an element against the nth-child pseudo cla
find_nth find_nth(ordinal, offset) Instance Protected methods
std::nth_element Defined in header <algorithm> template< class RandomIt > void nth_element( RandomIt first, RandomIt nth, RandomIt last ); (1)


Return to View
  • Facebook
  • Tweet
  • Digg it
  • Stumbleupon
  • Delicious
  • Plus Share

Designed by : w10schools

service@w10schools.com

Our Partners: aeeble – Providing content publishing and search solutions