DEV Community

Discussion on: Do you know these weird parts of JavaScript?

Collapse
 
dhanushkadev profile image
Dhanushka madushan

1 + "23" - 10 = 113
1 + "23" takes as string concatenation operation. The results is "123". Then it subtract 13.

Still not that clear how following things works.
[] + []

{} + {}
[] + {}
{} + []
+!+[]

Collapse
 
lqj profile image
QJ Li • Edited

I thought about +!+[], it could be like these (I may be wrong)

1. `+[]` is `0` 
2. `!0` is `true` 
3. `+true` is `1`
Collapse
 
dhanushkadev profile image
Dhanushka madushan

I think thats the solution. It's working on console.