Recent project contact, time is more adequate, to browse the Internet and stumbled on the Internet to find this problem, the predicted results and the real result is too big.
Please look at the following code
var a={n:1}
var b=a;
A.x=a={n:2}
Console.log (a.x);
Console.log (b.x);
Undefined
Object{n:2}
If we take the code apart, the result is what we think.
var a={n:1}
var b=a;
A={n:2};
A.x={n:2}
console.log (a.x);//object{n:2}
Console.log (b.x);//undefined
Analysis Code:
A.x=a={n:2}
JS assignment operation is right combination, above equivalent to a.x= (A={n:2})
JS evaluation operation is from left to right (PS: and colleagues discuss, he said is from left to right, I think it is from right to left, and finally found that I was wrong)
1) a.x= (final result in parentheses)
To find the X property of a that does not exist, add an attribute x to the object that a points to, and this X property assigns a result to it, well, I'm waiting for the result.
2) Because the result is to get the results in parentheses, then a.x is waiting to return the result in parentheses, so start the evaluation A={n:2} and return to the new property X
3) Back to the parentheses in the a={n:2},a occurred pointing to change the
JavaScript implementation gives <a href= "" > Href assignment
document.getElementById ("a"). href= ""; A is the ID of the hyperlink A that you want to add, such as <a id= ' a ' > info tip </a>
<form action= "" method= "Post" name= "MyForm" >
<a href = "" Id=links > Info </a >
</form >
<script >
document.getElementById ("links"). href= " Http://www.baidu.com ";
</script >
This code content implementation to <a hre= "" >href assignment, how the code is very simple.
The above content is this article uses the JavaScript to realize continuously assigns the value the entire content, hoped that has the help to everybody, this website has the new content renewal every day, continues to pay attention yo!