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

  • SEARCH
  • Home
  • 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 7797677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:45:41+00:00 2026-06-01T23:45:41+00:00

Possible Duplicate: What is the difference between substr and substring? I just want to

  • 0

Possible Duplicate:
What is the difference between substr and substring?

I just want to clarify this differences of:-

alert("abc".substr(0,2));
alert("abc".substring(0,2));

the above case both will return

ab

alert("abc".substr(1,2));
alert("abc".substring(1,2));

and the above case will return first bc and the second one b

so basically for the substr the second argument is the length it has to go?
and for substring it will stop but not include??

Please correct me if I’m wrong because we will have a quiz today and I don’t want to get this wrong again.

  • 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-06-01T23:45:42+00:00Added an answer on June 1, 2026 at 11:45 pm

    Yes, substr()‘s second parameter is the length of the required substring while substring()‘s is a character index, a fact which is pretty trivial to find via a web search.

    What is less well-known is that substr() is non-standard (up to and including ECMAScript 5; ES3 and ES5 have non-normative sections on substr()) and had some bugs in older versions of IE. Also, slice() is preferable to substring() because it allows negative character indices, counted backwards from the end of the string:

    alert( "Dandelion".slice(-4) ); // Alerts "lion"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Difference between int[] array and int array[] I was sure that this
Possible Duplicate: Difference between Activity Context and Application Context I want to know the
Possible Duplicate: difference between destructor and garbage collector Recently i asked this question ,
Possible Duplicate: Difference between a Structure and a Union in C I see this
Possible Duplicate: Difference between pointer variable and reference variable in C++ I saw this
Possible Duplicate: Difference between WIN32 and other c string I got this code inside
Possible Duplicate: difference between jsp forward and redirect Does anyone knows the differences between
Possible Duplicate: Calculating the Difference Between Two Java Date Instances In Java, I want
Possible Duplicate: Difference between Convert.tostring() and .tostring() Hi Carrying on from this question What
Possible Duplicate: Difference between pointer variable and reference variable in C++ When should I

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.