Transition from undefined to null. - Javascript Language Basics

Javascript examples for Language Basics:Introduction

Description

Transition from undefined to null.

Demo Code

ResultView the demo in separate window

<!DOCTYPE HTML>
<html>
    <head>
        <title>Example</title>
    </head>
    <body>
        <script type="text/javascript">

                  var myData = {/*w ww  . j  ava2 s  .  c o  m*/
                      name: "java2s.com",
                  };

                  document.writeln("Var: " + myData.topic);
                  document.writeln("Prop: " + ("topic" in myData));

                  myData.topic = "CSS";
                  document.writeln("Var: " + myData.topic);
                  document.writeln("Prop: " + ("topic" in myData));

                  myData.topic = null;
                  document.writeln("Var: " + myData.topic);
                  document.writeln("Prop: " + ("topic" in myData));

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

Related Tutorials