LoginSignup
1
0

More than 1 year has passed since last update.

【N】Null, Undefinedの違いを雰囲気で理解した気になりたい

Last updated at Posted at 2022-12-13

これ、言語化難しいよね〜

Nullとは?

『"なにも無い"がある』

Undefinedとは?

『"無い"』

違い

Nullはある、Undefinedはない

『"なにも無い"がある』ってつまり無いってことじゃんと思ってはいけない

例え

郵便配達

Null……その住所が示す場所は存在するが、そこに家はない
Undefined……そんな住所はない

変数を箱で例えて教えた人相手

Null……その箱はここにあるが、何も入っていない
Undefined……そんな名前の箱はない

課題

String型の空文字列""との区別もつけるとなるとやばいですよね
""も『"なにも無い"がある』じゃない?という疑問に答えるすべを僕はまだ持っていない

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0