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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:48:33+00:00 2026-06-02T23:48:33+00:00

Inspired by this video , I tested further with {}+[] . Test 1: typeof

  • 0

Inspired by this video, I tested further with {}+[].

Test 1:

typeof {}+[]  //"object"

Okay, so {}+[] is an object.

Test 2:

var crazy = {}+[];
typeof crazy  //"string"

What? Didn’t {}+[] is an object? Why is it a string now?

Test 3:

console.log({}+[])

What I got:

enter image description here

So it is a number!… No?

So what actually is the type of {}+[]??

UPDATED

To people who say {}+[] is a empty string:

{}+[] === ""     //false
({}+[]) === ""   //false
({};+[]) === ""  //SyntaxError
({}+[]).length   //15

JavaScript is so hard to understand…

  • 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-02T23:48:35+00:00Added an answer on June 2, 2026 at 11:48 pm

    Type of {}+[] may vary depending on the context.

    1. typeof {}+[] //"object"
      As per operators precedence in this case typeof {} evaluates to “object”, +[] adds an empty string(array is coerced to string) therefore result is “object”.
      You could think of checking typeof ({}+[]) (your second case).

    2. var crazy = {}+[];
      typeof crazy //"string"

      In this case you are adding object and array – they both coerce to string, therefore typeof returns “string”.

    3. {}+[]
      This is interpreted as an empty block of code, unary plus and empty array.
      First part does nothing, array is converted to a comma-separated string of it’s elements(empty string for empty array), then to a number(empty string is converted to 0), hence 0.

    UPDATED

    • {}+[] === "" //false
      see #3, {} is interpreted as a block, you are getting 0 on the left.
      Compare {}+[] === 0 // true.

    • ({}+[]) === "" //false
      see #1, {} is interpreted as an object literal. When trying to add array and object, they both convert to string, "[object Object]" for object and empty string for array. Hence, you are getting "[object Object]" on the left.
      Compare ({}+[]) === "[object Object]" // true.

    • ({};+[]) === "" //SyntaxError
      I guess, this one is self-explanatory 🙂

    • ({}+[]).length //15
      15 is exactly the length of "[object Object]", see above.

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

Sidebar

Related Questions

I created a simple application inspired by this example in order to test all
Inspired by this question I decided to test the rank() function, trying to see
Inspired by this discussion , after some googling I wasn't able to find an
This question is inspired by this question . I'd like to get a dictionary
My question is partially inspired by this article written by Eric Lippert: http://blogs.msdn.com/ericlippert/archive/2009/10/19/what-is-this-thing-you-call-thread-safe.aspx Using
Note: this was inspired by WebBrowser Event Properties? Why am I able to access
This is inspired by/taken from this thread: http://www.allegro.cc/forums/thread/603383 The Problem Assume the user gives
Inspired by the discussion in this question . We have all been taught that
This question is inspired by the article Why are Facebook, Digg, and Twitter so
Inspired by the encoding scheme of the answer to this question , I implemented

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.