Test case details

Preparation Code

var a = 1,         b = true,         c = "c",         d = [],         e = {},         u;         function isUndefinedA(thing) {           return typeof thing === 'undefined';     }         function isUndefinedB(thing) {           return thing === undefined;     }         var _undefined;         function isUndefinedC(thing) {           return thing === _undefined;     }         function isUndefinedD(thing) {           return thing === void 0;     }         function isUndefinedE(thing) {           return thing === void null;     }         // tests     var funcs = [isUndefinedA, isUndefinedB, isUndefinedC, isUndefinedD, isUndefinedE];     var vars = [a, b, c, d, e, u];         for (var f = 0; f < funcs.length; f++) {           var func = funcs[f];       for (var v = 0; v < vars.length; v++) {             var val = vars[v];         var isUndefined = func(val);         var expect;         if (v === 5) {               expect = true;         } else {               expect = false;         }             if (isUndefined !== expect) {               throw new Error('assert failure');         }       }     }

Test cases

Test #1

isUndefinedA(a); isUndefinedA(b); isUndefinedA(c); isUndefinedA(d); isUndefinedA(e); isUndefinedA(u);

Test #2

isUndefinedB(a); isUndefinedB(b); isUndefinedB(c); isUndefinedB(d); isUndefinedB(e); isUndefinedB(u);

Test #3

isUndefinedC(a); isUndefinedC(b); isUndefinedC(c); isUndefinedC(d); isUndefinedC(e); isUndefinedC(u);

Test #4

isUndefinedD(a); isUndefinedD(b); isUndefinedD(c); isUndefinedD(d); isUndefinedD(e); isUndefinedD(u);

Test #5

isUndefinedE(a); isUndefinedE(b); isUndefinedE(c); isUndefinedE(d); isUndefinedE(e); isUndefinedE(u);