I have been doing a code review 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 whether key can ever be undefined (or evaluated to true per angular.isUndefined). It seems unlikely, as when I try to do the following:
var a = { undefined: 'hello' }
It turns out that undefined is actually a String.
My question is whether
keycan ever beundefined
No. All keys (property names) of an object are converted to strings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With