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 8466489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:21:29+00:00 2026-06-10T15:21:29+00:00

I just tried this code in Chrome deveoper tools: var str = 1111111; str[0]

  • 0

I just tried this code in Chrome deveoper tools:

var str = "1111111";
str[0] = 2;
2
console.log(str[0]);
1

As you can see, the output was 1, where I expected 2. My conclusion is this is not meant to be working like that, so I ask how would I get this to work – how would I change the first ‘item’ of the varable str to 2?

  • 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-10T15:21:31+00:00Added an answer on June 10, 2026 at 3:21 pm

    That is because in JavaScript strings are immutable objects. You should use substr function:

    String.prototype.replaceAt = function (index, char) {
      return this.substr(0, index) + char + this.substr(index + char.length);
    };
    
    var str = '11111';
    console.log(str.replaceAt(0, '2'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is just some pretty standard code I have tried. What I am trying
Input: $string = this-is-just-an--example Output: this is just an-example Tried various things centered around
Edit: Just found out this is a chrome problem, the code works fine in
I've just tried some simple code from example: $(document).ready(function() { var map = OpenLayers.Map('map-content',
So I've tried this XHTML 1.1 code (validated at validator.w3.org) in Chrome 6, IE
I just tried the tooltip like this Easy image preview ... But i cant
I just tried to run my test app and I got this error: 2012-06-16
hope this will be a quick easy question, I've just tried my app on
I have tried troubleshooting this problem and just ended up with nothing, I hope
I tried doing this: [toolbar setTint:[UIColor colorWithPatternImage:[UIImage imageNamed:@thingFromMyBundle.png]]]; but it just ended up black.

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.