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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:39:01+00:00 2026-05-10T18:39:01+00:00

Is there some way I can define String[int] to avoid using String.CharAt(int) ?

  • 0

Is there some way I can define String[int] to avoid using String.CharAt(int)?

  • 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. 2026-05-10T18:39:02+00:00Added an answer on May 10, 2026 at 6:39 pm

    No, there isn’t a way to do this.

    This is a common question from developers who are coming to JavaScript from another language, where operators can be defined or overridden for a certain type.

    In C++, it’s not entirely out of the question to overload operator* on MyType, ending up with a unique asterisk operator for operations involving objects of type MyType. The readability of this practice might still be called into question, but the language affords for it, nevertheless.

    In JavaScript, this is simply not possible. You will not be able to define a method which allows you to index chars from a String using brackets.

    @Lee Kowalkowski brings up a good point, namely that it is, in a way, possible to access characters using the brackets, because the brackets can be used to access members of a JavaScript Array. This would involve creating a new Array, using each of the characters of the string as its members, and then accessing the Array.

    This is probably a confusing approach. Some implementations of JavaScript will provide access to a string via the brackets and some will not, so it’s not standard practice. The object may be confused for a string, and as JavaScript is a loosely typed language, there is already a risk of misrepresenting a type. Defining an array solely for the purposes of using a different syntax from what the language already affords is only gong to promote this type of confusion. This gives rise to @Andrew Hedges‘s question: ‘Why fight the language?’..

    There are useful patterns in JavaScript for legitimate function overloading and polymorphic inheritance. This isn’t an example of either.

    All semantics aside, the operators still haven’t been overridden.

    Side note: Developers who are accustomed to the conventions of strong type checking and classical inheritance are sometimes confused by JavaScript’s C-family syntax. Under the hood, it is working in an unfamiliar way. It’s best to write JavaScript in clean and unambiguous ways, in order to prevent confusion.

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

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Here's the lazy man's way of solving this problem: Use… May 11, 2026 at 11:25 am
  • added an answer If you are using JDK 7 use the new Files.createTempDirectory… May 11, 2026 at 11:25 am
  • added an answer Use git locally, and then git-cvsexportcommit would be my suggestion.… May 11, 2026 at 11:25 am

Related Questions

Is there some way I can define String[int] to avoid using String.CharAt(int) ?
Is there some way I can use URLs like: http://www.blog.com/team-spirit/ instead of http://www.blog.com/?p=122 in
Is there some way to get a value from the last inserted row? I
I want to show HTML content inside Flash. Is there some way to do
I don't think this is possible, but I'll ask anyway... Is there some way
Is there some built-in way to share files between Xen guests? I don't currently
I was wondering if there is some way to name or rename a property
I was just wondering whether there is some way to do this: I have
I would like to know if there is some way to share a variable
I'm trying to debug an MSBuild task, and I know there is some way

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.