why is the out put of
console.log(Object +1)
is
function Object() {
[native code]
}1
i tried it and expext a numeric value as the + description :
In this case, JS calls Object's toPrimitive method, which gives the following string:
function Object() {
[native code]
}
In the next step, JS converts 1(number) into the "1"(string), as the first operand is a string, after that it's just a concatenation of two strings that results in:
function Object() {
[native code]
}1
Here is the link for a detailed explanation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With