从对象中删除属性
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript 对象属性</h1>
- <p>您可以删除对象属性。</p>
- <p id="demo"></p>
- <script>
- var person = {
- firstname:"Bill",
- lastname:"Gates",
- age:62,
- eyecolor:"blue"
- };
- delete person.age;
- document.getElementById("demo").innerHTML =
- person.firstname + " is " + person.age + " years old.";
- </script>
- </body>
- </html>