当前位置: 首页 > 图文教程 > 网络编程 > Javascript > JS实例代码解析:以实例方式学习数组知识

Javascript
Add a Table to a Word Document
Add Formatted Text to a Word Document
用jscript实现新建word文档
用jscript实现新建和保存一个word文档
Open and Print a Word Document
Use Word to Search for Files
Convert Seconds To Hours
Sample script that deletes a SQL Server database
Sample script that displays all of the users in a given SQL Server DB
firefox中用javascript实现鼠标位置的定位
div+css实现鼠标放上去,背景跟图片都会变化。
Locate a File Using a File Open Dialog Box
Save a File Using a File Save Dialog Box
用jscript实现列出安装的软件列表
List the Stored Procedures in a SQL Server database
Display SQL Server Login Mode
Display SQL Server Version Information
List all the Databases on a SQL Server
用jscript启动sqlserver
Stop SQL Server

Javascript 中的 JS实例代码解析:以实例方式学习数组知识


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-03   浏览: 410 ::
收藏到网摘: n/a

<script language="javascript" type="text/javascript">
//创建变量testArray 并引用数组 ["1","2","3"]
var testArray = ["1","2","3"];
//引用数组 ,此时 变量 linkOne linkTwo testArray 均引用数组 ["1","2","3"]
var linkOne =linkTwo =testArray;
//修改testArray 引用数组 ["4","5","6"],此时 linkOne linkTwo 仍引用数组 ["1","2","3"]
testArray = ["4","5","6"]
//这里将返回 2
alert(linkTwo[1]);


//创建变量testObj 并引用对象 {one:"1",tow:"2",three:"3"}
var testObj = {one:"1",tow:"2",three:"3"}
//引用对象, 此时objLinkOne 引用 对象 {one:"1",tow:"2",three:"3"}
var objLinkOne = testObj
//修改对象
testObj.tow="133"
//testObj引用新对象{one:"4",tow:"5",three:"6"} objLinkOne仍引用原对象
testObj = {one:"4",tow:"5",three:"6"}
//这里将返回 133
alert(objLinkOne.tow);

//strTest 引用字符串 im
var strTest = "im";
//strTestNew 引用字符串 im
var strTestNew = strTest;
//strTestNew 引用新的字符串 im new str
strTestNew += " new str";
//这里将返回 im
alert(strTest);

</script>