Way2tutorial Snippet Editor
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JavaScript object deleting</title> </head> <body> <pre> <!-- Use pre element for work document.writeln() method --> <script type="text/javascript"> // Press F12 - View result on Console Panel var myObj = {}; // indicates an Object is created myObj.commercial = ".com"; myObj.network= ".net"; myObj.organization= ".org"; myObj.government= ".gov"; document.writeln("commercial domain: " + myObj['commercial']); // Outputs .com document.writeln("commercial domain: " + myObj.commercial); // Outputs .com delete myObj.commercial; console.log("After removing : ", myObj); </script> </pre> </body> </html>