Wednesday, October 8, 2025
HomeLanguagesJavascriptLodash _.endsWith() Method

Lodash _.endsWith() Method

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.  

The _.endsWith() method is used to check whether the string ends with the given target string or not.

Syntax:

_.endsWith([string=''], [target], [position=string.length])

Parameters: This method accepts three parameters as mentioned above and described below:

  • string: This parameter holds the string that need to inspect.
  • target: This parameter holds the string that need to search.
  • position: This parameter holds the position where search the string.

Return Value: This method returns true if string ends with target string, false otherwise.

Example 1:

Javascript




const _ = require('lodash'); 
  
var str1 = _.endsWith("neveropen", "s");
console.log(str1);
  
var str2 = _.endsWith("neveropen", "G");
console.log(str2);
  
var str3 = _.endsWith("neveropen", "Geeks");
console.log(str3);


Output:

true
false
true

Example 2:

Javascript




const _ = require('lodash'); 
  
var str1 = _.endsWith("GFG", "F", 2);
console.log(str1);
  
var str2 = _.endsWith("neveropen", "f", 5);
console.log(str2);
  
var str3 = _.endsWith("neveropen", "for", 8);
console.log(str3);


Output:

true
false
true
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32342 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6712 POSTS0 COMMENTS
Nicole Veronica
11875 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11937 POSTS0 COMMENTS
Shaida Kate Naidoo
6833 POSTS0 COMMENTS
Ted Musemwa
7092 POSTS0 COMMENTS
Thapelo Manthata
6786 POSTS0 COMMENTS
Umr Jansen
6789 POSTS0 COMMENTS