This test page demonstrates that there is no appreciable performance difference between testing whether a variable is undefined using the typeof
operator, versus doing a strict equality test against a variable that is deliberately not defined (ie. a proxy for the undefined value).
In the test, one iterator runs 100,000 times, each time performing a test using the typeof
operator 20 times. A second iterator also runs 100,000 times, each time performing a strict equality test against a deliberately undefined variable 20 times. A third iterator also runs 100,000 times, each time performing a strict equality test against undefined
20 times.