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 ...
随机推荐
- (转) SpringBoot:使用spring-boot-devtools进行热部署以及不生效的问题解决
在idea上怎么才能使用Spring的热部署 这里仅用Maven做介绍 (1)在Maven中添加依赖 (2)在插件配置 但是,为什么配置了还是没有用呢 ?! 这是因为idea默认是没有自动编译的,我们 ...
- 多线程-生产者消费者(BlockingQueue实现)
三.采用BlockingQueue实现 BlockingQueue也是java.util.concurrent下的主要用来控制线程同步的工具. BlockingQueue有四个具体的实现类,根据不同需 ...
- IDEA查看JDK源代码
之前已经讲解过如何使用Eclipse查看源代码,IDEA作为一个集成开发环境越来越流行,今天学习以下如何使用Eclipse查看JDK的代码. File->Project Structure,选择 ...
- 将Excel数据读入DataGridView
OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Microsoft Excel ...
- 51 Nod 阶乘后面0的数量
1003 阶乘后面0的数量 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 收藏 关注 n的阶乘后面有多少个0? 6的阶乘 = 1*2*3*4*5*6 = 72 ...
- 论文阅读:Offloading Distributed Applications onto SmartNICs using iPipe
摘要: 包含丰富计算资源的新兴多核SoC SmartNIC具有卸载通用数据中心服务器任务的潜力,但是目前尚不清楚如何有效地使用SmartNIC并最大程度地减少卸载收益,尤其是对于分布式应用程序. 为此 ...
- python27 错误汇总
一.TypeError: object of type 'NoneType' has no len() 解决的方法: 源代码:resp_data = None (None是一个空的对象) 修改后代码 ...
- 工具类-ApplicationContextUtil
package com.zhouyy.netBank.util; import org.springframework.beans.BeansException; import org.springf ...
- [BZOJ3611][Heoi2014]大工程(虚树上DP)
3611: [Heoi2014]大工程 Time Limit: 60 Sec Memory Limit: 512 MBSubmit: 2464 Solved: 1104[Submit][Statu ...
- 「HAOI 2018」染色
题目链接 戳我 \(Solution\) 观察题目发现恰好出现了\(s\)次的颜色有\(k\)种,不太好弄. 所以我们设\(a[i]\)表示为恰好出现了\(s\)次的颜色有至少\(i\)种的方案数,然 ...