4.1 primitive and reference values
ECMAScript variables may contains 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.
The five primitive types are: Undefined, Null, Boolean, Number and String.
primitive values are accessed by value, while reference values are accessed by reference.
Copying Values
Primitive and reference values act differently when copied from one variable to another.
When a primitive value is assigned from one variable to another, the value stored on the variable object is created and copied into the location for the new variable.
When a reference value is assigned from one variable to another, the value stored on the variable object is also copied into the location for the new variable. The different is that this value is actually a pointer to an object stored on the heap. Once the operation is complete, two variables point to exactly the same object, so changes to one are reflected on the other.
Argument Passing
When an argument is passed by value, the value is copied into a local variable(a named argument and, in ECMAScript, a slot in the arguments object). When an argument is passed by reference, the location of a value in memory is stored into a local variable, which means that changes to the local variable are reflected outside of the function .
4.1 primitive and reference values的更多相关文章
- Java中的原始类型(Primitive Types)与引用类型(Reference Values)
Java虚拟机可以处理的类型有两种,一种是原始类型(Primitive Types),一种是引用类型(Reference Types). 与之对应,也存在有原始值(Primitive Values)和 ...
- = splice
<script> function wf(w){ console.log(w); } var wa = [3,66,7]; var wb = wa; wa.splice(1,1); wf( ...
- 《javascript高级程序设计》第四章 Variables,scope,and memory
4.1 基本类型和引用类型的值 primitive and reference values 4.1.1 动态的属性 dynamic properties 4.1.2 复制变量值 copying va ...
- javascript fundamental concept
http://hzjavaeyer.group.iteye.com/group/wiki?category_id=283 上面这个url非常适合javascript初学者阅读,感谢原作者的分享 什么是 ...
- JavaScript 深入了解基本类型和引用类型的值
转载:https://segmentfault.com/a/1190000006752076 一个变量可以存放两种类型的值,基本类型的值(primitive values)和引用类型的值(refere ...
- spring源码分析(一)IoC、DI
创建日期:2016.08.06 修改日期:2016.08.07 - 2016.08.12 交流QQ:992591601 参考书籍:<spring源码深度解析>.<spring技术内幕 ...
- Java Data Type
官方文档:http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html 转载地址:http://blog.csdn.n ...
- Effective Java 08 Obey the general contract when overriding equals
When it's the case that each instance of the class is equal to only itself. 1. Each instance of the ...
- 面试准备(四)Java基本数据类型
Java语言是静态类型的(statical typed),也就是说所有变量和表达式的类型再编译时就已经完全确定.由于是statical typed,导致Java语言也是强类型(Strong typed ...
随机推荐
- java8学习之比较器详解与类型推断特例
比较器详解: 这次来对比较器进行一个学习,比较器(Comparator)这个是在JDK1.2就提出的概念,只是说JAVA8针对它进行了一定的扩充,更加方便咱们使用,其中唯一的抽象方法如下: 而JAVA ...
- pikachu-file
1.不安全的文件下载 1.1.概述 文件下载功能在很多web系统上都会出现,一般我们当点击下载链接,便会向后台发送一个下载请求,一般这个请求会包含一个需要下载的文件名称,后台在收到请求后 会开始执行下 ...
- Linux系统层级结构标准
Linux Foundation有一套标准规范: FHS: Filesystem Hierarchy[‘haɪərɑːkɪ] Standard(文件系统层级标准)目前最新的标准是2.3版本:http: ...
- [LeetCode 92] Reverse Linked List II 翻转单链表II
对于链表的问题,根据以往的经验一般都是要建一个dummy node,连上原链表的头结点,这样的话就算头结点变动了,我们还可以通过dummy->next来获得新链表的头结点.这道题的要求是只通过一 ...
- BZOJ1306 [CQOI2009]match循环赛/BZOJ3139 [Hnoi2013]比赛[dfs剪枝+细节题]
地址 看数据范围很明显的搜索题,暴力dfs是枚举按顺序每一场比赛的胜败情况到底,合法就累计.$O(3^{n*(n-1)/2})$.n到10的时候比较大,考虑剪枝. 本人比较菜所以关键性的剪枝没想出来, ...
- 问题-CHM文件不显示
原问题:http://bbs.csdn.net/topics/370230310 问题描述: http://download.csdn.net/download/wybneu/3582721 我从这个 ...
- ThinkPHP 模型方法 setInc() 和 setDec()
TP 内置了对统计数据(数字字段)的更新方法: setInc():将数字字段值增加 setDec():将数字字段值减少 $User::where('id=5')->setInc('score', ...
- python进阶ing——创建第一个Tornado应用
python进阶ing——创建第一个Tornado应用 分类: Python2013-06-02 23:02 1725人阅读 评论(2) 收藏 举报 pythonTornado 每天在群里跟很多群友讨 ...
- php的流程控制 if elseif swich case for循环
if ......else 最简形式: <?php if (true){ echo "晚上找昌仔训练去";}?> ...
- Tomcat部署多个Springboot项目报错 InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat
在一个tomcat服务器下部署了多个采用阿里druid作为数据连接池,结果启动报错.原因是不能在一个tomcat服务器下不能直接部署多个druid作为数据连接池的项目,需要配置. 解决办法: 在spr ...