zoukankan      html  css  js  c++  java
  • = splice

     1 <script>
     2     function wf(w){
     3         console.log(w);
     4     }
     5 
     6     var wa = [3,66,7];
     7     var wb = wa;
     8     wa.splice(1,1);
     9     wf(wa);
    10     wf(wb);
    11 
    12     var waa = [3,66,7];
    13     var wbb = waa;
    14     waa = [123,4];
    15     wf(waa);
    16     wf(wbb);
    17 
    18     var wae = [3,66,7];
    19     var wbe = wae;
    20     wbe.splice(1,1);
    21     wf(wae);
    22     wf(wbe);
    23 
    24     var arr = new Array();
    25     wf(arr);
    26 </script>

    [3, 7]
    [3, 7]


    [123, 4]
    [3, 66, 7]

    [3, 7]
    [3, 7]

    Professional.JavaScript.for.Web.Developers.3rd.Edition.Jan.2012

    4 Variables, Scope, and Memory

    PRIMITIVE AND REFERENCE VALUES
    ECMAScript variables may contain 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.
    When a value is assigned to a variable, the JavaScript engine must determine if it’s a primitive or a reference. The five primitive types were discussed in the previous chapter: Undefined, Null, Boolean, Number, and String. These variables are said to be accessed by value, because you are manipulating the actual value stored in the variable.
    Reference values are objects stored in memory. Unlike other languages, JavaScript does not permit direct access of memory locations, so direct manipulation of the object’s memory space is not allowed. When you manipulate an object, you’re really working on a reference to that object rather than the actual object itself. For this reason, such values are said to be accessed by reference.
  • 相关阅读:
    SVG ViewBox
    svg中改变class调用的线条颜色
    SVG 箭头线绘制
    Spring3中的mvc:interceptors标签配置拦截器
    MyBatis入门学习
    MyBatis 配置sql语句输出
    使用iBATIS3.0完成增删改查
    iBatis简单入门教程
    SpringMVC常用注解,返回方式,路径匹配形式,验证
    springMVC 返回类型选择 以及 SpringMVC中model,modelMap.request,session取值顺序
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6015438.html
Copyright © 2011-2022 走看看