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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:59:38+00:00 2026-05-31T15:59:38+00:00

{1 + ”} + 10 // 10 {1 + ”} + ” // 0

  • 0
{1 + ''} + 10 // 10
{1 + ''} + '' // 0

Why does this happen? Do BlockStatements return 0, and why?

  • 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-31T15:59:39+00:00Added an answer on May 31, 2026 at 3:59 pm

    Do BlockStatements return 0…?

    No, blocks return the value of the last expression within them. You can see this by just doing:

    {1 + 8}
    

    …in the JavaScript console, which will show 9.

    {1 + ''} + 10 // 10

    {1 + ''} + '' // 0

    Why does this happen?

    Because although the block does return a value, that value is not used. {1 + ''} + 10 // 10 code is evaluated as two distinct items:

    {1 + ''} // "1"
    +10      // 10
    

    …or writing those with standard indentation and semicolons:

    {
        1 + '';
    }
    +10;
    

    …and you’re seeing the result of the second one, as though the first one weren’t there at all. The + there isn’t the addition operator, it’s the unary + (similar to the unary -, but it doesn’t change the sign of its operand). +10 is, of course, 10; and +'' is 0 because applying the operator to a string converts the string to a number, and Number('') is 0.

    You can prove that you’re seeing the unary + rather than the addition operator by trying this:

    {1 + ''} * 10
    

    …which is really

    {
        1 + '';
    }
    *10;
    

    It fails with a syntax error because there is no unary *.

    As Felix kindly points out in the comments below, for the + in your example to be the addition operator (which would have ended up concatenating strings, in your case), it would have to be between two expressions, and a block is a statement, not an expression.

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

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I want to change all headers, normally this is quite easy (and it probably
Does anyone know of a clean and easy way to truncate a section of
Why does the following segfault, and how can I prevent it? <?php $str =
This is in Visual Studio 2010 IDE. I need to remove the quotes from
this is what i have right now Drawing an RSS feed into the php,
I'm looking for a way to convert text like this: <!DOCTYPE html PUBLIC \-//W3C//DTD
in this code I'm trying to Listening to multi connection at the same time
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
How does one open a semicolon delimited CSV file with VBA in Excel 2000?

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.