JavaScript 对象是易变的
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript 对象是易变的</h1>
- <p>对对象副本的任何更改也将更改原始对象。</p>
- <p id="demo"></p>
- <script>
- var person = {firstName:"Bill", lastName:"Gates", age:62, eyeColor:"blue"}
- var x = person;
- x.age = 10;
- document.getElementById("demo").innerHTML =
- person.firstName + " is " + person.age + " years old.";
- </script>
- </body>
- </html>