Kinda… container.name
is indeed undefined
which is a special value in JS; however by concatenating it to a string in this line
console.log("container is now a "+container.name);
you’re implicitly coercing the value of undefined
to the string 'undefined'
, which again is not actually undefined
. So the expression container.name == 'undefined'
will evaluate to false
, while
if (container.name == undefined) {
// ...
}
would pass your test.