<script>
function wf(w){
console.log(w);
} var wa = [3,66,7];
var wb = wa;
wa.splice(1,1);
wf(wa);
wf(wb); var waa = [3,66,7];
var wbb = waa;
waa = [123,4];
wf(waa);
wf(wbb); var wae = [3,66,7];
var wbe = wae;
wbe.splice(1,1);
wf(wae);
wf(wbe); var arr = new Array();
wf(arr);
</script>

[3, 7]
[3, 7]

[123, 4]
[3, 66, 7]

[3, 7]
[3, 7]

Professional.JavaScript.for.Web.Developers.3rd.Edition.Jan.2012

4 Variables, Scope, and Memory

PRIMITIVE AND REFERENCE VALUES
ECMAScript variables may contain two different types of data: primitive values and reference values.
Primitive values are simple atomic pieces of data, while reference values are objects that may be made up of multiple values.
When a value is assigned to a variable, the JavaScript engine must determine if it’s a primitive or a reference. The five primitive types were discussed in the previous chapter: Undefined, Null, Boolean, Number, and String. These variables are said to be accessed by value, because you are manipulating the actual value stored in the variable.
Reference values are objects stored in memory. Unlike other languages, JavaScript does not permit direct access of memory locations, so direct manipulation of the object’s memory space is not allowed. When you manipulate an object, you’re really working on a reference to that object rather than the actual object itself. For this reason, such values are said to be accessed by reference.

= splice的更多相关文章

  1. JavaScript中的slice,splice,substr,substring,split的区别

    万恶的输入法,在sublime中会显示出繁体字,各位看官见谅. 1.slice()方法:该方法在数组和string对象中都拥有. var a = [1,2,3,4,5,6]; var s = 'thi ...

  2. splice() 方法向/从数组中添加/删除项目,然后返回被删除的项目

    删除位于 index 2 的元素,并添加一个新元素来替代被删除的元素: <script type="text/javascript"> var arr = new Ar ...

  3. JS 中 Array.slice() 和 Array.splice()方法

    slice slice()就是对应String的substring()版本,它截取Array的部分元素,然后返回一个新的Array: var arr = ['A', 'B', 'C', 'D', 'E ...

  4. subString(), subStr(),splice(),split()的区别

    1.slice(): Array和String对象都有 在Array中  slice(i,[j]) i为开始截取的索引值,负数代表从末尾算起的索引值,-1为倒数第一个元素 j为结束的索引值,缺省时则获 ...

  5. JavaScript中的splice方法

    splice方法根据传入的不同参数可分别实现删除和插入操作 使用splice(pra1,pra2,pra3)方法,需要为其提供如下参数: 1.pra1为其起始索引(即希望开始添加元素的地方) 2.pr ...

  6. 数组操作splice

    今天,实现某个功能时需要操作数组, var  array=[1,2,3,3,4]; console.log(array);           //结果: 1,2,3,3,4 var data=arr ...

  7. Array.splice()理解记忆

    var arr = [0,1,2,3,4,5,6,7,8,9]; arr.splice(0,0,"添加项1"); //arr => ["添加项",0,1, ...

  8. split,slice,splice,replace的用法

    split()方法用于把一个字符串分割成字符串数组 str.split("字符串/正则表达式从该参数制定额地方分割str",可选,可指定返回数组的最大长度,如果没设置参数,整个字符 ...

  9. JS splice() 定义和用法

    定义和用法 splice() 方法向/从数组中添加/删除项目,然后返回被删除的项目. 注释:该方法会改变原始数组. 语法 arrayObject.splice(index,howmany,item1, ...

  10. php js => splice 数组 插入 功能

    php    array_splice 手册详解 array_splice   - 把数组中的一部分去掉并用其它值取代 参数 input 输入的数组. offset 如果 offset 为正,则从 i ...

随机推荐

  1. FFmpeg源代码结构图

    转自:http://blog.csdn.net/leixiaohua1020/article/details/44220151 FFmpeg的库函数源代码分析文章列表: [架构图] FFmpeg源代码 ...

  2. Word2013对公式处理:样式、自动编号、交叉引用

    因快写毕业论文,专门研究了一下Word2013对公式的处理,有一点小心得,记在这里. 文章中公式展示的预期效果是:公式居中,尾端有编号,同时在文章中可以实现引用.实现该效果有很多方法,这里就说一种,其 ...

  3. ☆ fragment和fragmentactivity解析 (转)

    一.为什么要使用Fragment  1.当我们需要动态的多界面切换的时候,就需要将UI元素和Activity融合成一 个模块.在2.3中我们一般通过各种Activity中进行跳转来实现多界面的跳转和单 ...

  4. SQL Server SA 密码丢失无法连接数据库怎么办?

    如果Windows账户无法连接并且SA密码也丢失了,那么如何可以连接到数据库呢? 答案是: 在单用户模式下启动SQL Server然后用本地管理员权限连接.登陆之后就可以修改SA密码了. 步骤: 1. ...

  5. SQL2005备份数据库到远程服务器中

    --打开高级设置EXEC sp_configure 'show advanced options', 1RECONFIGURE--打开xp_cmdshell扩展存储过程EXEC sp_configur ...

  6. Loadrunner关联

    学习LoadRunner之关联(二) Lr学习之关联-随机删除一行数据和全部删除数据 录制一个系统,我录制的是一个交通方面的系统,登陆到系统里面,查询车牌颜色,将其中一条数据删除. "Nam ...

  7. CodeForces 656B

    C - C Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status ...

  8. 2016.6.23 PHP实现新闻发布系统主体部分

    1.新闻发布系统的列表: <html><meta http-equiv="Content-Type" content="text/html; chars ...

  9. SU suphasevel命令学习

  10. Codeforces Round #292 (Div. 2)

    A. Drazil and Date 无算法,判断(s - (a + b)) % 2是否为零,若零,表示在s步内还能走向其他的地方并且回来 否则,都是No #include <cstdio> ...