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的更多相关文章

  1. Java中的原始类型(Primitive Types)与引用类型(Reference Values)

    Java虚拟机可以处理的类型有两种,一种是原始类型(Primitive Types),一种是引用类型(Reference Types). 与之对应,也存在有原始值(Primitive Values)和 ...

  2. = splice

    <script> function wf(w){ console.log(w); } var wa = [3,66,7]; var wb = wa; wa.splice(1,1); wf( ...

  3. 《javascript高级程序设计》第四章 Variables,scope,and memory

    4.1 基本类型和引用类型的值 primitive and reference values 4.1.1 动态的属性 dynamic properties 4.1.2 复制变量值 copying va ...

  4. javascript fundamental concept

    http://hzjavaeyer.group.iteye.com/group/wiki?category_id=283 上面这个url非常适合javascript初学者阅读,感谢原作者的分享 什么是 ...

  5. JavaScript 深入了解基本类型和引用类型的值

    转载:https://segmentfault.com/a/1190000006752076 一个变量可以存放两种类型的值,基本类型的值(primitive values)和引用类型的值(refere ...

  6. spring源码分析(一)IoC、DI

    创建日期:2016.08.06 修改日期:2016.08.07 - 2016.08.12 交流QQ:992591601 参考书籍:<spring源码深度解析>.<spring技术内幕 ...

  7. Java Data Type

    官方文档:http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html 转载地址:http://blog.csdn.n ...

  8. 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 ...

  9. 面试准备(四)Java基本数据类型

    Java语言是静态类型的(statical typed),也就是说所有变量和表达式的类型再编译时就已经完全确定.由于是statical typed,导致Java语言也是强类型(Strong typed ...

随机推荐

  1. 解决 Jenkins 乱码以及命令不存在的问题

    方法一: Jenkins----系统管理----系统设置----全局属性----勾选环境变量 键 LANG 值 zh_CN.UTF-8 方法二(如果脚本用的是python): PYTHONIOENCO ...

  2. k8s资源需求及资源限制

    在k8s上,可由容器或pod请求或消费的计算资源时指cpu和内存,这也是目前仅有的受支持的两种类型.相比较来说,cpu属于可压缩资源,即资源额度可按需收缩,而内存则是不可压缩型资源,对其执行收缩操作可 ...

  3. sql 创建数据库并对数据库更改排序规则

    use master -- 设置当前数据库为master,以便访问sysdatabases表 go if exists(select * from sysdatabases where name='t ...

  4. php上传文件代码解析

    思想:把html的input标签组织成一个数组,然后去重 关键技术涉及的函数 is_dir mkdir move_uploaded_file() 涉及的数组 预定义数组$_FILES 步骤一:检查上传 ...

  5. qt5---事件过滤器

  6. Celery分布式异步任务框架

    一.什么是Celery Celery是一个简单.灵活且可靠的,处理大量消息的分布式系统.专注于实时处理的异步任务队列,同时也支持定时任务 二.Celery架构 1.Celery的架构由三部分组成: 消 ...

  7. 论文阅读:Forwarding Metamorphosis: Fast Programmable Match-Action Processing in Hardware for SDN

    摘要: 在软件定义网络中,控制平面在物理上与转发平面分离,控制软件使用开放接口(例如OpenFlow)对转发平面(例如,交换机和路由器)进行编程. 本文旨在克服当前交换芯片和OpenFlow协议的两个 ...

  8. PX4学习之-uORB msg 自动生成模板解读

    最后更新日期 2019-06-22 一.前言 在 PX4学习之-uORB简单体验 中指出, 使用 uORB 进行通信的第一步是新建 msg.在实际编译过程中,新建的 msg 会转换成对应的 .h..c ...

  9. JavaWeb_(SSH论坛)_六、点赞模块

    基于SSH框架的小型论坛项目 一.项目入门 传送门 二.框架整合 传送门 三.用户模块 传送门 四.页面显示 传送门 五.帖子模块 传送门 六.点赞模块 传送门 七.辅助模块 传送门 联合主键 创建p ...

  10. 数据预测算法-ARIMA预测

    简介 ARIMA: AutoRegressive Integrated Moving Average ARIMA是两个算法的结合:AR和MA.其公式如下: 是白噪声,均值为0, C是常数. ARIMA ...