Question #29

Author: admin
tags: JavaScript  
const a = {
  m: 10,
  toString() { return this.m; },
};

const b = 5;

console.log(a + b);
What will the console output be?
5
10
15
'105'
'510'
NaN
There will be an error
The interpreter tries to convert the object to a primitive.
The object does not have a [Symbol.ToPrimitive] method, so the toString method is called.
It doesn't matter that the name of this method has the word String. What matters is what it returns.
As a result, it turned out:
10 + 5
Rate the difficulty of the question:
easyhard