Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7515735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:54:13+00:00 2026-05-30T00:54:13+00:00

string.lastIndexOf(searchValue[, fromIndex]) MDN says that fromIndex default value is equal to the string.length ,

  • 0

string.lastIndexOf(searchValue[, fromIndex])

MDN says that fromIndex default value is equal to the string.length, however, I really think it is string.length-1

But it doesn’t matter what I think… I need someone to confirm what is the default value of fromIndex

Here is what they say:

“It can be any integer between 0 and the length of the string. The default value is the length of the string.”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:54:14+00:00Added an answer on May 30, 2026 at 12:54 am

    According to ECMAScript 5, it will be the length of the String.

    15.5.4.8 String.prototype.lastIndexOf (searchString, position)

    If position is undefined, the length of the String value is assumed, so as to search all of the String.

    …

    1. Call CheckObjectCoercible passing the this value as its argument.
    2. Let S be the result of calling ToString, giving it the this value as its argument.
    3. Let searchStr be ToString(searchString).
    4. Let numPos be ToNumber(position). (If position is undefined, this step produces the value NaN).
    5. If numPos is NaN, let pos be +∞; otherwise, let pos be ToInteger(numPos).
    6. Let len be the number of characters in S.
    7. Let start min(max(pos, 0), len).
    8. Let searchLen be the number of characters in searchStr.
    9. Return the largest possible nonnegative integer k not larger than start such that k+ searchLen is not greater than len, and for all nonnegative integers j less than searchLen, the character at position k+j of S is the same as the character at position j of searchStr; but if there is no such integer k, then return the value -1.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my code: private static string AddURISlash(string remotePath) { if (remotePath.LastIndexOf(/) != remotePath.Length
string strLine;//not constant int index = 0; while(index < strLine.length()){//strLine is not modified}; how
String's in C# are immutable and threadsafe. But what when you have a public
String[] a = c.toArray(new String[0]); First: Do I need type cast here? (I think
String processing in C# and VB.NET is easy for me, but understanding how to
Can anyone help me find the LastIndexOf '\' in a string in java? I
This apple is my apple.lastIndexOf(apple); // returns value of 17 This apple is my
2 days ago, there was a question related to string.LastIndexOf(String.Empty) returning the last index
Just a short question out of curiosity. string str = string; Console.WriteLine(str.EndsWith(string.Empty)); //true Console.WriteLine(str.LastIndexOf(string.Empty)
I have a string path = c:\inetpub\wwwrroot\images\pdf\admission.pdf I am using this path = path.LastIndexOf(\\).ToString();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.