Laboratory · JavaScript Lab
JavaScript coercion experiment
Briefing
Is JavaScript coercion arbitrary, or is there a single spec algorithm that explains every famous example?
`[] + []` is an empty string. `[] + {}` is an object tag. `{} + []` is zero, but only in a console. All of it follows one algorithm.
- Laboratory
- JavaScript Lab
- Level
- DEVELOPER
- Estimated time
- 7 minutes
- Method
- interactive
- Variables under observation
- ToPrimitivevalueOftoStringabstract equalitytype coercion