当前位置: 代码迷 >> JavaScript >> js 摘引
  详细解决方案

js 摘引

热度:398   发布时间:2012-06-30 17:20:12.0
js 引用

<html>

<head>
<script type="text/javascript">
// js 引用
var item = new Array("one","two");
var itemRef = item;
//item和itemRef指向同一个对象(Array)的指针
item.push("three");
alert(item.length==itemRef.length);
itemRef.push("three");
alert(item.length==itemRef.length);
itemRef = new Array("one","two","three");
alert(item == itemRef);

var it = "test";

var itRef = it;

item += "ing";//创建新对象

alert(it!=ifRef);
</script>
<body>


</body>

</head>

</html>

  相关解决方案