What does mental yoga mean in the following sentence?
The isNaN() function requires some
mental yogaat times because it attempts to prove a negative—that the value in a variable is not a number.
Yoga here is being used as a metaphor for flexibility.
Because the function attempts to do what's widely considered impossible -- proving a negative -- it demands that you stretch your mind a bit to comprehend it.
In addition to mental yoga, you might run into the phrase mental gymnastics, which has largely the same meaning.