JS Dasar: Undefined

by istiq20

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Undefined</title>
  </head>
  <body>
    <script>

      let name;
      if (name === undefined) {
        console.info("UNDEFINED"); // UNDEFINED
      } else {
        console.info("DEFINED");
      }

      const names = ["Eko", "Kurniawan"];
      if (names[2] === undefined) {
        console.info("ARRAY UNDEFINED"); // ARRAY UNDEFINED
      } else {
        console.info("ARRAY DEFINED");
      }

      const person = {};
      if (person.name === undefined) {
        console.info("OBJECT UNDEFINED"); // OBJECT UNDEFINED
      } else {
        console.info("OBJECT DEFINED");
      }

    </script>
  </body>
</html>