Instance Analysis of JavaScript object
This article introduces the relevant knowledge of "JavaScript object instance Analysis". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
JavaScript objects are mutable
Objects are mutable: they are addressed by reference, not by value.
If person is an object, the following statement does not create a copy of person:
Var x = person; / / this does not create a copy of person.
Object x is not a copy of person. It is person. X and person are the same object.
Any change to x will change person because x and person are the same object.
Example
Var person = {firstName: "Bill", lastName: "Gates", age:62, eyeColor: "blue"}
Var x = person
X.age = 10; / / this will change both both x.age and person.age
Note: JavaScript variables are not mutable. Only JavaScript objects do this.
This is the end of "JavaScript object instance Analysis". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!