My answer was that it's impossible. They said nothing is impossible. It happened 2 weeks back, but I'm still trying to find the answer.
The interviewer should have gone into much more depth instead of (presumably) marking that question as failed and moving on. This was a perfect opportunity to find out more about the interviewee's knowledge of Javascript instead of whether they immediately knew the answer to a trick question.
The interviewer could have asked about the difference between "==" and "===" operators, which any experienced Javascript developer should know at least a little about.
Then they could have asked if the interviewee knows how "==" converts types before comparing them, and find out if they know that it uses .toString() and .valueOf().
Then the interviewer could have asked about if those functions can be overridden, and how that can be done.
At this point, the interviewee's eyes may have lit up and they may have been able to solve the original question.
This approach would have given the interviewer information about the interviewee's knowledge of: "==" vs "===" operators, .toString() and .valueOf() functions, function overriding, and object variables. Instead the only knowledge that the interviewer learned was whether the interviewee had seen a similar problem before or was able to immediately recognize the answer.