Delete operator on Object : delete « Language Basics « JavaScript DHTML






Delete operator on Object

 

<html>
<head>
    <title>The Delete Operator</title>
    <script type = "text/javascript" >

    var aObject = {};
    
    aObject["A"] = new Object;
    aObject["B"] = new Object;
    aObject["C"] = new Object;
    aObject["D"] = new Object;
    
    aObject["A"].myValue = "a";
    aObject["B"].myValue = "b";
    aObject["C"].myValue = "c";
    aObject["D"].myValue = "d";

    </script>
</head>
<body id = "mainbody">
<script type = "text/javascript">

    delete(aObject["A"].myValue);

    for (obj in aObject) {
        var para = document.createElement('paragraph');
        para.id = obj;
        para.appendChild(document.createTextNode(obj + ": " + aObject[obj].myValue));
        document.getElementsByTagName("body")[0].appendChild(para);
    }
    
</script>

</body>
</html>

   
  








Related examples in the same category