Addition of an object and empty array

in both the cases it is showing output [object Object]
but it should show 0 in the first case and [object Object] in the second case

You are logging {}+[]
That is why you are getting [object Object]
Instead of console.log({} + []) see the output without console.log()
i.e. Open the browser console and type {} + [] (without console.log)

To explain the difference between the two different outputs (i.e. 0 and [object Object]), you need to read about LHS and RHS lookup.
Read this: https://dev.to/maeganwilson_/lhs-rhs-look-ups-12ma

After reading the article, now understand that when you write:
console.log({} + [])
Here we perform a RHS lookup of {}, which is an empty object. So it is basically adding empty object and empty array.
While in case of:
{} + []
we are performing a LHS lookup of {}, which is just an empty block of code. So basically we are trying adding an empty code block and empty array.

Fore reference, here are some cases where RHS lookup is performed:

  1. Anything right of = is RHS
  2. Anything in function argument is also RHS
  3. Anything after a mathematical operator is also RHS

I know what are you saying that’s why i am asking the question why both the statement are giving same output. Instead of giving {} + [] = 0 it is giving [object Object]. And console.log is function of interpreter which gives output so {} + [] should give 0 value on ide also or webstorm rather it is showing
[object Object]. It shouldn’t matter the platform the main task is of interpreter.

When you pass something as an argument, always the RHS lookup is followed. The RHS lookup of {} is an empty object.
But when you write {}+[] without passing to it as parameter to console.log, LHS lookup is considered. LHS lookup of {} is an empty block of code.

The platform here matters because you can only see the output on online ide with console.log(), while on a web browser, or an interpreter the result of each statement is printed.

So if you are saying LHS lookup is done by console.log then [] + {} should give zero but instead it is giving object Object

I said passing any parameter to console.log will invoke RHS lookup, not LHS lookup.

And for []+{}, for both cases LHS and RHS, the lookup for [] is an empty array. After that an mathematical operator + is there. When a mathematical operator is reached, then always the RHS lookup is done for further part of the expression. The rhs of {} is an empty object. So basically it is an array + object in both cases (with or without console.log)

@rishu1450 Is your doubt solved now?