I know that:
console.log({}.length);
> undefined
console.log([].length);
> 0
console.log([] + {});
> [object Object]
but,why ([] + {})
is [object Object]
console.log(([] + {}).length);
> 15
Why...I can't figure out
I know that:
console.log({}.length);
> undefined
console.log([].length);
> 0
console.log([] + {});
> [object Object]
but,why ([] + {})
is [object Object]
console.log(([] + {}).length);
> 15
Why...I can't figure out
My console gives me this:
typeof []
"object"
typeof {}
"object"
typeof [] + {}
"object[object Object]"
typeof ([] + {})
"string"
The length of your last console.log is because it is a string.