Today, at work, I noticed that I didn't notice the place before, that is, if an object is assigned to another variable or object through the assignment operator "=", then the value or data of the object is not stored in the variable or object that receives the value, but only the this pointer to the object.
For example:
var x = {' A ': 1}var y = x; The variable y holds not the contents of object X, but a this pointer, whose source is still the object X
So, once we have changed the contents of the variable y, the X object as the source will also change.
1 var x = {' A ': 1}2var y = x; 3 y.a=2 = x.a==2
If you want the variable y to hold the contents of object X, and you change the action variable y without changing the object x, you can only copy the object!
var function (obj) { var result = {}; for (var in obj) { typeof obj=== "Object"? CopyObject (Obj[x]): obj[x] }
return result;}
------------------------------------------------Gorgeous split-line---------------------------------------------
In addition to the above harvest, but also solves a IE8 css hack problem.
1 . IE8{2 background:red\9;3 /*ie6-8; The first scenario: This scenario is often written in a CSS style sheet*/4 5 background:red\\9;6 /*ie6-8; Scenario Two: When this scheme can be used in inline styles*/7 8 background:red\0;9 /*Ie8-edge Support*/Ten}
2015/12/14-Object assignment problem and Ie8hack