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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:39:56+00:00 2026-05-21T02:39:56+00:00

I tried extending native Objects using operators. It works. Would there be side effects

  • 0

I tried extending native Objects using operators. It works. Would there be side effects you can think of?

Number.prototype['+++'] = function(n){
    return this + (2*n);
};

String.prototype['+'] = function(){
    return this += [].slice.call(arguments).join('');
}

alert( 10['+++'](10) ); //=> 30
alert( 'hello '['+']('world ','and ','see you later!') ); 
      //=> hello world and see you later!

see also this jsfiddle

  • 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-21T02:39:56+00:00Added an answer on May 21, 2026 at 2:39 am

    There shouldn’t be any side effects to what you’re doing. Just keep in mind that you don’t call what you’re doing “operator overloading,” or users of your code might think they can actually use the operators. You may also want to ask yourself, “does this really make writing code any easier?”

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

Sidebar

Related Questions

I would like to create a component(extending from spark Panel), which upon a buttonclick
I have a class that is already extending TabActivity so i can't extend ListActivity.
For parsing an xml response using TagSoup I am extending the DefaultHandler, now I
I'm using Yii to construct a web application. One of my input forms has
I'm extending the tellerick RadGrid control to give it an optional CustomSearchControl. protected override
While extending a sample Android activity that fires some other activities from its menu,
Really struggling to figure out extending the immutable Set with a class that will
Here's my canvas class extending JPanel : package start; import java.awt.Color; import java.awt.Graphics; import
I have simple 2D puzzle game earlier I created it extending view and everything
I am trying to create template/BaseActivity class for other developers to use, as a

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.