Намунаи 18
<html>
<head>
<meta charset='utf-8'/>
<title>Намунаи 18, Объект дар функсия</title>
</head>
<body>
<p id="demoX"></p>
<p id="demoY"></p>
<p id="demoX_new"></p>
<p id="demoY_new"></p>
<script type="text/javascript">
<!--
var myObj = { X:null, Y:null };
myObj.X = prompt("Адади X-ро дохил намоед:", 5);
if (myObj.X != null) {
document.getElementById("demoX").innerHTML = "X = " + myObj.X;
}
myObj.Y = prompt("Адади Y-ро дохил намоед:", 6);
if (myObj.Y != null) {
document.getElementById("demoY").innerHTML = "Y = " + myObj.Y;
}
console.log(myObj);
document.write("Ибтидои даъвати функсия<br>");
myFunction(myObj);
document.write("Интихои даъвати функсия<br>");
console.log(myObj);
//document.write("X = " + myObj.X + "<br>");
//document.write("Y = " + myObj.Y + "<br>");
document.getElementById("demoX_new").innerHTML = "X = " + myObj.X;
document.getElementById("demoY_new").innerHTML = "Y = " + myObj.Y;
//myObj.x = X;
//myObj.y = Y;
function myFunction(obj) {
var t = obj.Y;
obj.Y = obj.X;
obj.X = t;
//alert("Test");
console.log(obj);
}
//-->
</script>
</body>
</html>