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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:50:59+00:00 2026-06-18T00:50:59+00:00

Why is it that this code evaluates to: 10 + 10 => 1010 10

  • 0

Why is it that this code evaluates to:

10 + "10" => "1010"
"10" + 10 => "1010"

and why does it not work like this:

10 + "10" => 20 // the number comes first
"10" + 10 => "1010" // the string comes first   

EDIT:

More specifically, where in the implementation of the interpreter does it do this? Or, how does it do this?

  • 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-18T00:51:00+00:00Added an answer on June 18, 2026 at 12:51 am

    The ECMAScript 262 Specification codifies the JavaScript language (JavaScript is actually the Mozilla implementation of ECMAScript). In any case, things are relatively easy to find in Annotated ES5 which I usually consult.

    See 11.6.1 The Addition operator ( + ):

    The addition operator either performs string concatenation or numeric addition.

    The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression is evaluated as follows:

    1. Let lref be the result of evaluating AdditiveExpression.
    2. Let lval be GetValue(lref).
    3. Let rref be the result of evaluating MultiplicativeExpression.
    4. Let rval be GetValue(rref).
    5. Let lprim be ToPrimitive(lval).
    6. Let rprim be ToPrimitive(rval).
    7. If Type(lprim) is String or Type(rprim) is String, then
      Return the String that is the result of concatenating ToString(lprim) followed by ToString(rprim)
    8. Return the result of applying the addition operation to ToNumber(lprim) and ToNumber(rprim). See the Note below 11.6.3.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I assume that :parent_id evaluates to a number. But, how exactly does this piece
EDIT: I realized that this code compiles and works: #include <iostream> template<class Something> class
In this code that uses the mongodb-native driver I'd like to increase the value
I was under the impression that this code #include <windows.h> #include <stdio.h> int WINAPI
I was playing around with some Javascript snippets today and noticed that this code
I found that this C++ code: vector<int> a; a.push_back(1); a.push_back(2); vector<int>::iterator it = a.begin();
I have the following code: Bear in mind that while this code works on
I have this code that I've edited: http://pastebin.com/vrqHek6S I've put in comments where I
I have this code that runs but never stops. class A { public static
I have this code that reads from XML file. It gets five strings (groupId,

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.