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. 团队作业-Beta冲刺(周四)

    一. 这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass1/ 这个作业要求在哪里 https://edu.c ...

  2. 第五章Java

    2 [单选题] 已知MyInterface是一个接口,ClassA是实现该接口的一个类,ClassB是ClassA的子类,则下面说法哪个正确?   A. ClassB obj = new ClassA ...

  3. HTML左边盒子固定,右边盒子自适应

    html: <div class="box1"> <div class="divA">DIVA</div> <div ...

  4. lazarus中的TSQLQuery注意事项

    lazarus中的TSQLQuery相当于delphi中的TClientDataSet,必须  SQLQuery.ApplyUpdates;  SQLTransaction.Commit; 数据才能提 ...

  5. jmeter测试报告添加报告生成日期时间

    <!-- Defined parameters (overrideable) --><xsl:param name="showData" select=" ...

  6. js 创建节点 以及 节点属性 删除节点

    case 'copy': var B1 = document.getElementById("B1"); //获得B1下的html文本 var copy_dom = documen ...

  7. C# image/byte[]/string/互转

    public Image ByteArrayToImage(byte[] iamgebytes) { MemoryStream ms = new MemoryStream(iamgebytes); I ...

  8. C# Winform程序之间如何传递和接收参数 Process

    Program: static class Program    { /// <summary>         /// 应用程序的主入口点.         /// </summa ...

  9. C# 1.0(2002)

    序言 C# 1可以看做2001年Java语言的升级版. 主要功能 类 结构 接口 事件 属性 委托 表达式 语句 特性 值类型和引用类型 装箱和拆箱 资料

  10. codevs 5960 信使x

    题目描述 Description •战争时期,前线有n个哨所,每个哨所可能会与其他若干个哨所之间有通信联系.信使负责在哨所之间传递信息,当然,这是要花费一定时间的(以天为单位).指挥部设在第一个哨所. ...