delete





js/script.js
  • var Obj = {
  •  val: 10,
  •  str: 'Hello World!'
  • }
  •  
  • delete Obj.val;
  •  
  • function funMake() {
  •  document.write(Obj.val + '<br />');
  •  document.write(Obj.str + '<br />');
  • }
var Obj = {
 val: 10, 
 str: 'Hello World!'
}

delete Obj.val;

function funMake() {
 document.write(Obj.val + '
'); document.write(Obj.str + '
'); }


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  • <script>
  •  funMake();
  • </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  • <script>
  •  funMake();
  • </script>
  • </body>
  • </html>