!!( " ")
!!("")
!!(undefined === null)
You probably want to test for any falsey value though. So the interviewee understanding the ToBoolean spec [0] would be what you actually want to be testing for. if (!x) {
// interviewee should be able to answer for which values of `x` this condition would run
// this shows they understand which values are falsey and which values are truthy
}
The knowledge being tested would be "the same" but in a different, and I feel more direct, way. I felt your test was testing their knowledge of implicit conversion and not truthy/falsey values, so I wrote purposefully confusing code that uses implicit conversion."If everyone can easily understand what's going on, there's no harm writing code like that!" /s
[0] http://www.ecma-international.org/ecma-262/6.0/index.html#se...
What you test on is almost as important as how you test on it. Interviews go both ways after all. I think a majority of people aren't disagreeing that a professional should know these things - but asking them to "rattle off an answer to [question]" is looked down on. It reeks of the "reverse a binary tree" or "implement [some sorting algorithm]" type of questions.
I consider myself a Javascript professional (in so much that I am paid primarily for the Javascript work I do) and I had no issue knowing the answer to the three items listed. If I was asked to rattle them off the top of my head as some sort of Fizzbuzz Filter equivalent - I'd thank you for your time and leave the interview.
I agree people should know the answers - which (as you've pointed out) is the point you're trying to get across. But how you share that point, much like which questions you ask, is important.
And it still amazes me that this position seems to be controversial here on HN. There are people who have expressed unequivocal agreement, to be sure, but a significant number seem to see that stuff as obscure arcana that a developer would not typically need to know.