That, or you’re met with “why on earth do you want to do that?”
To be fair, the XY problem is huge in anything coding related. Newbie wants to do X, has a vague and terribly wrong idea about how to do it (Y), then asks how to do Y instead. To give a "correct" answer to Y, assuming the question makes enough sense to have a correct answer, is less helpful than trying more or less tactfully to figure out what the actual goal was.
Give some JS dev about fifteen minutes