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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:06:45+00:00 2026-05-24T11:06:45+00:00

For JavaScript in most browsers*, you can read a character from a String by

  • 0

For JavaScript in most browsers*, you can read a character from a String by treating it like an Array. However, in all the browsers I’ve tried (IE9, Chrome, Firefox), you can’t write to it like an Array.

For example:

var string = 'hello world';
alert(string[0]);//alerts 'h'
alert(string);//alerts 'hello world'

string[0]='j';
alert(string[0]);//alerts 'h'
alert(string);//alerts 'hello world'

This has repercussions for more than just JavaScript developers:

jelloPeople.roam();

Does anybody know the reasoning behind this?

For example, I’ve looked at Mozilla’s documentation, and they allude to it but don’t give an explanation:

    “..trying to set a character via indexing does not throw an error, but the string itself is unchanged.”

Bottom Line: It is strange and confusing to me that some array properties were given to Strings and not others.

UPDATE:

Ok, so JavaScript Strings are immutable objects, but why? It seems like operations such as the above would be faster if they weren’t immutable (change 1 character as opposed to making a new 11 character string). In fact, I don’t see a case with String functions where performance would be impacted negatively if they weren’t immutable, but I see several where performance would be improved. Also, there is no true multi-threading in JavaScript, so no advantage to immutables there.

(removed and will research this and possibly ask in a new quesion)


*Not IE 6 or 7

  • 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-24T11:06:46+00:00Added an answer on May 24, 2026 at 11:06 am

    This simply because javascript strings are immutable by design; once created they cannot be changed.

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

Sidebar

Related Questions

I know most mobile browsers don't support javascript, how can I check this?
Most people talk about progressive enhancement right now as serving browsers with javascript (enhanced
Most JavaScript code is also syntactically valid ActionScript 3.0 code. However, there are some
Most of my development life, I have done a JavaScript generated button like so:
Most of the tutorials that I've read on arrays in JavaScript (including w3schools and
Can someone please correct my code here. It works well in most browsers but
Most of javascript and web development books/articles says that you must put CSS in
Possible Duplicate: What is the most efficient way to clone a JavaScript object? I
What's the best and most efficient way to count keywords in JavaScript? Basically, I'd
What would be the most idiomatic way to do the following in JavaScript: If

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.