You have a typo where the second instance of let belief = null; should presumably be let belief = undefined;.
(Also, I think “It’d print an error saying that foobar is not defined” is false? Confirmed by going to the browser console and running that two-liner; it just prints undefined to the console.)
It’s a little tough because in terms of how beliefs map to JavaScript types I think the mapping to undeclared makes more sense, but describing the nuance of how an undeclared variable differs from an undefined one in JavaScript feels a little excessive for this post.
But I also don’t like having something in the post that is so blatantly wrong. I’ll try to come up with something and edit the post.
You have a typo where the second instance of let belief = null; should presumably be let belief = undefined;.
I somehow lost sight of the fact that undeclared variables aren’t seen as undefined. I’ll try to update the post.
(Also, I think “It’d print an error saying that foobar is not defined” is false? Confirmed by going to the browser console and running that two-liner; it just prints undefined to the console.)
Hm. I get Uncaught ReferenceError: foobar is not defined.
You have a typo where the second instance of
let belief = null;
should presumably belet belief = undefined;
.(Also, I think “It’d print an error saying that
foobar
is not defined” is false? Confirmed by going to the browser console and running that two-liner; it just printsundefined
to the console.)Interesting mapping, otherwise!
I think he’s intentionally trying to describe an undeclared variable, and doesn’t realize that an undeclared variable is different from
undefined
.Yeah, I lost sight of that somehow. Whoops.
It’s a little tough because in terms of how beliefs map to JavaScript types I think the mapping to undeclared makes more sense, but describing the nuance of how an undeclared variable differs from an
undefined
one in JavaScript feels a little excessive for this post.But I also don’t like having something in the post that is so blatantly wrong. I’ll try to come up with something and edit the post.
I somehow lost sight of the fact that undeclared variables aren’t seen as
undefined
. I’ll try to update the post.Hm. I get
Uncaught ReferenceError: foobar is not defined
.Thanks!