Copy reference during assignment for object in JavaScript
Description
The following code shows how to copy reference during assignment for object.
Example
<!-- www .j a v a 2s . c om-->
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var obj1 = new Object();
var obj2 = obj1;
obj1.name = "JavaScript";
document.writeln(obj2.name); //"JavaScript"
obj1.name = "HTML";
document.writeln(obj2.name); //"HTML"
</script>
</head>
<body>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Variable
Create a code with three level of execution...
Define a variable outside a function and ca...
Demonstrate that there are no Block-Level S...
Demonstrate that variable defined with var ...
Demonstrate that variable defined without v...
Demonstrate that variables created by the v...
Find out the difference between primitive w...
Use eval to evaluate dynamic expressions in...
Use typeof operator to check if a variable ...
Copy reference during assignment for object...
Copy value from one primitive type to anoth...Create a code with three level of execution...
Define a variable outside a function and ca...
Demonstrate that there are no Block-Level S...
Demonstrate that variable defined with var ...
Demonstrate that variable defined without v...
Demonstrate that variables created by the v...
Find out the difference between primitive w...
Use eval to evaluate dynamic expressions in...
Use typeof operator to check if a variable ...