Is it possible to have undefined as a key when traversing a JavaScript object?
I am reviewing the code and I see code like this:
var a = { ... }; // in reality, an actual object filled with key-value pairs
for (var key in a) {
if (!angular.isUndefined(key)) { // does this ever fail?
do.stuff();
}
}
My question is, can it key
be undefined (or be evaluated as true
for angular.isUndefined
). This seems unlikely since when I try the following:
var a = { undefined: 'hello' }
It turns out that undefined
actually a String
.
+3
source to share