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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:43:10+00:00 2026-06-14T06:43:10+00:00

a=12345 a[2]=3 a[2]=’9′ console.log(a) //=> 12345 What is going on?? This quirk caused me

  • 0
a="12345"
a[2]=3
a[2]='9'
console.log(a) //=> "12345"

What is going on?? This quirk caused me 1 hour painful debugging. How to avoid this in a sensible way?

  • 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-14T06:43:11+00:00Added an answer on June 14, 2026 at 6:43 am

    You cannot use brackets to rewrite individual characters of the string; only ‘getter’ (i.e. read) access is available. Quoting the doc (MDN):

    For character access using bracket notation, attempting to delete or
    assign a value to these properties will not succeed. The properties
    involved are neither writable nor configurable.

    That’s for “what’s going on” part of the question. And for “how to replace” part there’s a useful snippet (taken from an answer written long, long ago):

    String.prototype.replaceAt = function(index, char) {
        return this.slice(0, index) + char + this.slice(index+char.length);
    }
    

    You may use as it is (biting the bullet of extending the JS native object) – or inject this code as a method in some utility object (obviously it should be rewritten a bit, taking the source string as its first param and working with it instead of this).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to match the '12345' from a url in this form: http://domain.com/folder/title_of_this_12345 So
Let's say I've a string 12345 I should obtain all subsequence combinations of this
I have a html table like this: Invoice# Due Date Balance Select 12345 12/25/2011
My table contains entries with name like this: 12345 A12345 234567 A234567 A99999 I'd
So I have a CSV file that looks like this: 12345, Here is some
I have a list like this: [(ip1, video1, 12345.00000),(ip1, video1, 12346.12362),(ip1, video1, 12347.12684),(ip1, video2,12367.12567),(ip2,
In this code: FormatFloat('0.##########',XX.AsFloat) If the value XX in the database is 12.12345, what
How would I go and split number 12345 into something like this with PHP:
I have a view that looks like this: http://whatever/Download/viaId/12345 And i would like to
My URL looks like this: domain.com/12345/some-product-category and with the optional pagination: domain.com/12345-2/some-product-category so far

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.