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. 关于Vue-$router传参出现刷新页面或者返回页面丢失数据的问题

    也算是踩到坑了,但不是我踩到的,不过还是得说下这个问题,很严重,对于小白和初学者是比较有帮助的,如果使用到路由传参,请选择你想要的传参方式params或者query 1.query this.$rou ...

  2. python django 重新安装不能创建项目

    这里仅给大家做个思路提醒: 1.如果在别的地方找到一样的问题那就按别的方法去解决 2.如果是创建startproject的时候 报错:no module named 'mysite'  这个的话就和 ...

  3. java代码调用exe(cmd命令)

    public class ShellCommand{    public static void execCmd(String cmd, boolean wait)    {        execC ...

  4. 2019.12.9java公文流转系统

    自己来写这个系统真是没有什么思路.就弄了个登陆界面,在数据库建了个表,其它的代码一直有错误,登陆不进去.

  5. LVS+Heartbeat安装部署文档

    LVS+Heartbeat安装部署文档 发表回复 所需软件: ipvsadm-1.24-10.x86_64.rpmheartbeat-2.1.3-3.el5.centos.x86_64.rpmhear ...

  6. Http的通信机制?

    HTTP协议即超文本传送协议(Hypertext Transfer Protocol  ),是Web联网的基础,也是手机联网常用的协议之一,HTTP协议是建立在TCP协议之上的一种应用. HTTP连接 ...

  7. C# 扩展、常用方法

    项目基本做完了,抽空整理下里面用到的扩展方法,以及复用度很高的代码,省的以后到处去找. 一.C#扩展方法——Distinct去重 二.C#扩展方法——获得枚举Description 三.C#扩展方法— ...

  8. PHP入门(五)

    一.超级全局变量 超级全局变量在PHP 4.1.0之后被启用, 是PHP系统中自带的变量,在一个脚本的全部作用域中都可用. PHP中预定义了几个超级全局变量(superglobals) ,这意味着它们 ...

  9. JavaScript 正则表达式——预定义类,边界,量词,贪婪模式,非贪婪模式,分组,前瞻

    ㈠预定义类    示例:匹配一个ab+数字+任意字符的字符串:ab\d.   ㈡边界 正则表达式常用的边界匹配字符   ⑴示例1:第一个是没写单词边界             第二个是加上字符边界的效 ...

  10. JavaScript 正则表达式——定义,目的,特点,语法,字符串方法,search() ,replace() ,test(),exec()

    ㈠什么是正则表达式? ⑴正则表达式,又称规则表达式.(英语:Regular Expression,在代码中常简写为regex.regexp或RE),计算机科学的一个概念.    正则表达式通常被用来检 ...