简体   繁体   English

原始值与参考值

[英]Primitive value vs Reference value

I read a book called "Professional Javascript for web developer" and it says: "Variable is assigned by Reference value or Primitive Value. Reference values are objects stored in memory".我读了一本名为“Web 开发人员的专业 Javascript”的书,它说:“变量由引用值或原始值分配。引用值是存储在内存中的对象”。 And then it says nothing about how Primitive value is stored.然后它没有说明原始值是如何存储的。 So I guess it isn't stored in memory.所以我想它没有存储在内存中。 Based on that, when I have a script like this:基于此,当我有这样的脚本时:

var foo = 123;

How does Javascript remember the foo variable for later use? Javascript 如何记住foo变量以备后用?

Okay, imagine your variable to be a piece of paper - a sticky note.好的,假设您的变量是一张纸 - 一个便签。

Note 1: A variable is a sticky note .注 1:变量便签

Now, a sticky note is very small.现在,便签非常小。 You can only write a little bit of information on it.你只能在上面写一点信息。 If you want to write more information you need more sticky notes, but that's not a problem.如果你想写更多的信息,你需要更多的便签,但这不是问题。 Imagine you have an endless supply of sticky notes.想象一下,您有无穷无尽的便利贴。

Note 2: You have an endless supply of sticky notes, which store small amounts of information.注意 2:您有无穷无尽的便签,其中存储了少量信息。

Great, what can you write on your sticky note?太好了,你可以在便签上写什么? I can write:我可以写:

  1. Yes or no (a boolean ).是或否(布尔值)。
  2. My age (a number ).我的年龄(一个数字)。
  3. My name (a string ).我的名字(一个字符串)。
  4. Nothing at all ( undefined ).什么都没有(未定义)。
  5. A doodle or anything else which means nothing to me at all ( null ).涂鸦或其他任何对我来说毫无意义的东西( null )。

So we can write simple things (let's be condescending and call them primitive things) on our sticky notes.所以我们可以在便利贴上写一些简单的东西(让我们居高临下地称它们为原始的东西)。

Note 3: You can write primitive things on your sticky notes.注3:您可以在便签上写原始的东西。

So say I write 30 on a sticky note to remind myself to buy 30 slices of cheese for the little party I'm throwing at my place tonight (I have very few friends).因此,假设我在便利贴上写了30 ,以提醒自己为今晚我在我家举办的小聚会买 30 片奶酪(我的朋友很少)。

When I go to put my sticky note on the fridge I see that my wife has put another sticky note on the fridge which also says 30 (to remind me that her birthday is on the 30th of this month).当我去把我的便利贴贴在冰箱上时,我看到我妻子在冰箱上贴了另一张便利贴,上面也写着30 (提醒我她的生日是这个月的 30 号)。

Q: Do both the sticky notes convey the same information?问:两个便签都传达了相同的信息吗?

A: Yes, they both say 30 . A:是的,他们都说30 We don't know if it's 30 slices of cheese or the 30th day of the month, and frankly, we don't care.我们不知道是 30 片奶酪还是一个月的第 30 天,坦率地说,我们不在乎。 For a person who didn't know any better, it's all the same.对于一个不知道更好的人来说,一切都一样。

var slicesOfCheese = 30;
var wifesBirthdate = 30;

alert(slicesOfCheese === wifesBirthdate); // true

Note 4: Two sticky notes which have the same thing written on them convey the same information, even though they are two different sticky notes.注释 4:两个写有相同内容的便签传达相同的信息,即使它们是两个不同的便签。

I'm really excited about tonight - hanging out with old friends, having a great time.今晚我真的很兴奋——和老朋友一起出去玩,玩得很开心。 Then some of my friends call me and say that they won't be able to make it to the party.然后我的一些朋友打电话给我,说他们将无法参加聚会。

So I go to my fridge and erase the 30 on my sticky note (not my wife's sticky note - that would make her very angry) and make it a 20 .所以我去我的冰箱,把我便利贴上的30擦掉(不是我妻子的便利贴——那会让她很生气)并把它变成20

Note 5: You can erase what's written on a sticky note and write something else.注 5:您可以擦除便利贴上写的内容并写其他内容。

Q: That's all good and fine, but what if my wife wanted to make write a list of groceries for me to pick up while I was out to get some cheese.问:这一切都很好,但如果我的妻子想要写一份杂货清单,让我在出去买奶酪的时候去拿,该怎么办? Would she need to write a sticky note for every item?她是否需要为每件物品写一个便利贴?

A: No, she would take a long list of paper and write the list of groceries on that paper. A:不,她会拿一长串纸,然后在纸上写下食品清单。 Then she would write a sticky note telling me where to find the list of groceries.然后她会写一张便条,告诉我在哪里可以找到杂货清单。

So what's happening here?那么这里发生了什么?

  1. A list of groceries is obviously not simple (erm... primitive ) data.杂货清单显然不是简单的(呃...原始)数据。
  2. My wife wrote it on a longer piece of paper.我妻子把它写在一张更长的纸上。
  3. She wrote where to find it in a sticky note.她在便利贴中写下了在哪里可以找到它。

Honey, the list of groceries is under your keyboard.亲爱的,杂货清单在你的键盘下面。

To recap:回顾一下:

  1. The actual object (the list of groceries) is under my keyboard.实际对象(杂货清单)在我的键盘下。
  2. The sticky note tells me where to find it (the address of the object).便利贴告诉我在哪里可以找到它(对象的地址)。

Note 6: Reference values are references to objects (addresses where they will be found).注 6:引用值是对对象(将被找到的地址)的引用。

Q: How do we know when two sticky notes say the same thing?问:我们怎么知道两个便签说的是同一件事? Say my wife made another grocery list in case I misplaced the first, and wrote another sticky note for it.假设我的妻子制作了另一个购物清单,以防我放错了第一个,并为它写了另一个便利贴。 Both the lists say the same thing, but do the sticky notes say the same thing?两个列表都说同样的话,但便利贴是否说同样的话?

A: No. The first sticky note tells us where to find the first list.答:不可以。第一个便签告诉我们在哪里可以找到第一个列表。 The second one tells us where to find the second list.第二个告诉我们在哪里可以找到第二个列表。 It doesn't matter whether the two lists say the same thing.这两个列表是否说相同的事情并不重要。 They are two different lists.它们是两个不同的列表。

var groceryList1 = ["1 dozen apples", "2 loaves of bread", "3 bottles of milk"];
var groceryList2 = ["1 dozen apples", "2 loaves of bread", "3 bottles of milk"];

alert(groceryList1 === groceryList2); // false

Note 7: Two sticky notes convey the same information only if they refer to the same object.注 7:两个便签仅在指代同一对象时传达相同的信息。

This means if my wife made two sticky notes reminding me where the grocery list is, then the two sticky notes contain the same information.这意味着,如果我的妻子做了两个便利贴提醒我购物清单在哪里,那么这两个便利贴包含相同的信息。 So this:所以这:

Honey, the list of groceries is under your keyboard.亲爱的,杂货清单在你的键盘下面。

Contains the same information as:包含与以下相同的信息:

Don't forget that the list of groceries is under your keyboard.不要忘记杂货清单在您的键盘下方。

In programming terms:在编程方面:

var groceryList1 = ["1 dozen apples", "2 loaves of bread", "3 bottles of milk"];
var groceryList2 = groceryList1;

alert(groceryList1 === groceryList2); // true

So that's all that you need to know about primitives and references in JavaScript.这就是您需要了解的有关 JavaScript 中的原语引用的全部内容。 No need to get into things like heap and dynamic memory allocation.无需涉及和动态内存分配之类的内容。 That's important if you're programming in C/C++.如果您使用 C/C++ 编程,这很重要。

Edit 1: Oh, and the important thing is that when you pass variables around you're essentially passing primitive values by value and reference values by reference .编辑1:哦,最重要的事情是,当你传递变量身边你基本上传递的原始的价值参考价值的参考

This is just an elaborate way of saying that you're copying everything written on one sticky note to another (it doesn't matter whether you're copying a primitive value or a reference ).这只是一种精心设计的说法,即您将一个便利贴上写的所有内容复制到另一个便利贴(无论您复制的是原始值还是引用都无关紧要)。

When copying references, the object being referenced doesn't move (eg my wife's grocery list will always stay under my keyboard, but I can take the sticky note I copied anywhere I want - the original sticky note will still be on the fridge).复制引用时,被引用的对象不会移动(例如,我妻子的购物清单将始终保留在我的键盘下,但我可以将复制的便利贴带到任何我想要的地方——原始便利贴仍将在冰箱上)。

Edit 2: In response to the comment posted by @LacViet:编辑 2:回应@LacViet 发表的评论:

Well for starters we're talking about JavaScript, and JavaScript doesn't have a stack or a heap .对于初学者来说,我们谈论的是 JavaScript,而 JavaScript 没有stackheap It's a dynamic language and all the variables in JavaScript are dynamic.它是一种动态语言,JavaScript 中的所有变量都是动态的。 To explain the difference I'll compare it to C.为了解释差异,我将它与 C 进行比较。

Consider the following C program:考虑以下 C 程序:

#include <stdio.h>

int main() {
    int a = 10;
    int b = 20;
    int c = a + b;
    printf("%d", c);
    return 0;
}

When we compile this program we get an executable file.当我们编译这个程序时,我们会得到一个可执行文件。 The executable file is divided into multiple segments (or sections).可执行文件被分成多个段(或节)。 These segments include the stack segment, the code segment, the data segment, the extra segment, etc.这些段包括堆栈段、代码段、数据段、额外段等。

  1. The stack segment is used to store the state of the program when a function or interrupt handler is called.堆栈段用于在调用函数或中断处理程序时存储程序的状态。 For example, when function f calls function g then the state of function f (all the values in the registers at that time) are saved in a stack.例如,当功能f调用函数g然后功能的状态f (在此时的寄存器的所有值)被保存在堆栈中。 When g returns control to f then these values are restored.g将控制权返回给f这些值就会恢复。
  2. The code segment holds the actual code to be executed by the processor.代码段保存要由处理器执行的实际代码。 It contains a bunch of instructions the processor must execute like add eax, ebx (where add is the opcode, and eax & ebx are arguments).它包含一系列处理器必须执行的指令,如add eax, ebx (其中add是操作码, eax & ebx是参数)。 This instruction adds the contents of registers eax and ebx and stores the result in the register eax .该指令将寄存器eaxebx的内容相加,并将结果存储在寄存器eax
  3. The data segment is used to reserve space for variables.数据段用于为变量保留空间。 For example, in the above program, we need to reserve space for the integers a , b and c .例如,在上面的程序中,我们需要为整数abc保留空间。 In addition, we also need to reserve space for the string constant "%d" .此外,我们还需要为字符串常量"%d"保留空间。 Variables reserved thus have a fixed address in memory (after linking and loading).保留的变量因此在内存中具有固定地址(在链接和加载之后)。
  4. In addition to all of these, you're also give a little bit of extra space by the Operating System.除了所有这些之外,操作系统还为您提供了一些额外的空间。 This is called the heap.这称为堆。 Any extra memory you need is allocated from this space.您需要的任何额外内存都从此空间分配。 Memory allocated in this way is called dynamic memory.以这种方式分配的内存称为动态内存。

Let's see a program with dynamic memory:让我们看一个具有动态内存的程序:

#include <stdio.h>
#include <malloc.h>

int main() {
    int * a = malloc(3 * sizeof(int));

    a[0] = 3;
    a[1] = 5;
    a[2] = 7;

    printf("a: %d\nb: %d\nc: %d\n", a[0], a[1], a[2]);

    return 0;
}

Because we want to allocate memory dynamically we need to use pointers.因为我们想动态分配内存,所以需要使用指针。 This is because we want to use the same variable to point to an arbitrary memory location (not necessarily the same memory location every time).这是因为我们想要使用相同的变量来指向任意内存位置(不一定每次都相同的内存位置)。

So we create an int pointer ( int * ) called a .所以我们创建了一个名为aint指针( int * )。 The space for a is allocated from the data segment (ie it's not dynamic).对于空间a从数据段中被分配(即它不是动态的)。 Then we call malloc to allocate the contiguous space for 3 integers from the heap.然后我们调用malloc为堆中的 3 个整数分配连续空间。 The memory address of the first int is returned and stored in the pointer a .返回第一个int的内存地址并存储在指针a

Q: What did we learn?问:我们学到了什么?

A: A fixed amount of space is allocated for all variables.答:为所有变量分配了固定数量的空间。 Each variable has a fixed address.每个变量都有一个固定地址。 We may also allocate extra memory from the heap and store the address of this extra memory in a pointer.我们也可以从堆中分配额外的内存,并将这个额外内存的地址存储在一个指针中。 This is called a dynamic memory scheme.这称为动态内存方案。

Conceptually this is similar to what I explained about variables being sticky notes.从概念上讲,这类似于我解释的变量是便签。 All variables (including pointers are sticky notes).所有变量(包括指针都是便签)。 However, pointers are special because they reference a memory location (which is like referencing an object in JavaScript).然而,指针是特殊的,因为它们引用一个内存位置(这就像在 JavaScript 中引用一个对象)。

However, this is where the similarities end.然而,这就是相似之处。 Here are the differences:以下是差异:

  1. In C everything is passed by value (including addresses in pointers).在 C 中,一切都是按值传递的(包括指针中的地址)。 To pass a reference you need to use indirection via pointers.传递引用,您需要通过指针使用间接。 JavaScript only passes primitives by value. JavaScript 仅按值传递原语。 Passing references is handled transparently by the engine and is just like passing any other variable.传递引用由引擎透明处理,就像传递任何其他变量一样。
  2. In C you can create a pointer to a primitive data type like int .在 C 中,您可以创建指向原始数据类型(如int的指针。 In JavaScript, you cannot create a reference to a primitive value like number .在 JavaScript 中,您不能创建对像number这样的原始值的引用。 All primitives are always stored by value.所有原语总是按值存储。
  3. In C you may perform various operations on pointers.在 C 中,您可以对指针执行各种操作。 This is called pointer arithmetic.这称为指针算术。 JavaScript doesn't have pointers. JavaScript 没有指针。 It only has references.它只有参考。 Thus you can't perform any pointer arithmetic.因此你不能执行任何指针运算。

Besides these three the biggest difference between C and JavaScript is that all variables in JavaScript actually pointers.除了这三个之外,C 和 JavaScript 的最大区别在于 JavaScript 中的所有变量实际上都是指针。 Because JavaScript is a dynamic language the same variable may be used to store a number and a string at different points of time.因为 JavaScript 是一种动态语言,所以可以使用相同的变量在不同的时间点存储numberstring

JavaScript is an interpreted language, and the interpreter is usually written in C++. JavaScript 是一种解释型语言,解释器通常是用 C++ 编写的。 Thus all variables in JavaScript are mapped to objects in the host language (even primitives).因此,JavaScript 中的所有变量都映射到宿主语言中的对象(甚至是原语)。

When we declare a variable in JavaScript the interpreter creates a new generic variable for it.当我们在 JavaScript 中声明一个变量时,解释器会为它创建一个新的通用变量。 Then when we assign it a value (be it a primitive or a reference) the interpreter simply assigns a new object to it.然后,当我们为其分配一个值(无论是原始值还是引用)时,解释器只是为其分配一个新对象。 Internally it knows which objects are primitive and which are actually objects.它在内部知道哪些对象是原始对象,哪些是实际对象。

Conceptually it's like doing something like this:从概念上讲,这就像做这样的事情:

JSGenericObject ten = new JSNumber(10); // var ten = 10;

Q: What does this mean?问:这是什么意思?

A: It means that all the values (primitives and objects) in JavaScript are allocated from the heap. A:这意味着 JavaScript 中的所有值(原语和对象)都是从堆中分配的。 Even the variables themselves are allocated from the heap.甚至变量本身也是从堆中分配的。 It's wrong to state that primitives are allocated from the stack and only objects are allocated from the heap.说原语是从堆栈中分配的,而只有对象是从堆中分配的,这是错误的。 This is the biggest difference between C and JavaScript.这是 C 和 JavaScript 最大的区别。

A variable can hold one of two value types: primitive values or reference values . variable可以保存两种值类型之一: primitive valuesreference values

  • Primitive values are data that are stored on the stack . Primitive values是存储在堆栈上的数据。
  • Primitive value is stored directly in the location that the variable accesses. Primitive value直接存储在变量访问的位置。
  • Reference values are objects that are stored in the heap . Reference values是存储在堆中的对象
  • Reference value stored in the variable location is a pointer to a location in memory where the object is stored.存储在变量位置的Reference value是指向存储对象的内存位置的指针。
  • Primitive types include Undefined , Null , Boolean , Number , or String .原始类型包括UndefinedNullBooleanNumberString

The Basics:基础知识:

Objects are aggregations of properties.对象是属性的聚合。 A property can reference an object or a primitive .一个属性可以引用一个object或一个primitive Primitives are values , they have no properties. Primitives are values ,它们没有属性。

Updated:更新:

JavaScript has 6 primitive data types: String , Number , Boolean , Null , Undefined , Symbol (new in ES6). JavaScript 有 6 种原始数据类型: StringNumberBooleanNullUndefinedSymbol (ES6 中的新内容)。 With the exception of null and undefined, all primitives values have object equivalents which wrap around the primitive values, eg a String object wraps around a string primitive.除了 null 和 undefined 之外,所有原始值都具有环绕原始值的对象等效项,例如String对象环绕字符串原始值。 All primitives are immutable.所有原语都是不可变的。

In javascript the Primitive values are data that are stored on the stack .在 javascript 中, Primitive values是存储在stack上的数据

Primitive value is stored directly in the location that the variable accesses. Primitive value直接存储在变量访问的位置。

And the Reference values are objects that are stored in the heap . Reference values是存储在heap对象

Reference value stored in the variable location is a pointer to a location in memory where the object is stored.存储在变量位置的引用值是指向存储对象的内存位置的指针。

JavaScript supports five primitive data types: number, string, Boolean, undefined, and null . JavaScript 支持五种原始数据类型: number, string, Boolean, undefined, and null

These types are referred to as primitive types because they are the basic building blocks from which more complex types can be built.这些类型被称为原始类型,因为它们是可以构建更复杂类型的基本构建块。

Of the five, only number, string, and Boolean are real data types in the sense of actually storing data.在这五种类型中,从实际存储数据的角度来看,只有number, string, and Boolean是真正的数据类型。

Undefined and null are types that arise under special circumstances. Undefined and null是在特殊情况下出现的类型。 The primitive type has a fixed size in memory. primitive type在内存中具有固定大小。 For example, a number occupies eight bytes of memory, and a boolean value can be represented with only one bit.例如,一个数字占用 8 个字节的内存,而一个布尔值只能用一位来表示。

And the Reference types can be of any length -- they do not have a fixed size.并且引用类型可以是任意长度——它们没有固定的大小。

A primitive type has a fixed size in memory.原始类型在内存中具有固定大小。 For example, a number occupies eight bytes of memory, and a boolean value can be represented with only one bit.例如,一个数字占用 8 个字节的内存,而一个布尔值只能用一位来表示。 The number type is the largest of the primitive types.数字类型是最大的原始类型。 If each JavaScript variable reserves eight bytes of memory, the variable can directly hold any primitive value.如果每个 JavaScript 变量保留 8 个字节的内存,则该变量可以直接保存任何原始值。

This is an oversimplification and is not intended as a description of an actual JavaScript implementation.这是一种过度简化,并不打算作为实际 JavaScript 实现的描述。

Reference types are another matter, however.然而,引用类型是另一回事。 Objects, for example, can be of any length -- they do not have a fixed size.例如,对象可以是任意长度——它们没有固定的大小。 The same is true of arrays: an array can have any number of elements.数组也是如此:一个数组可以有任意数量的元素。 Similarly, a function can contain any amount of JavaScript code.同样,一个函数可以包含任意数量的 JavaScript 代码。 Since these types do not have a fixed size, their values cannot be stored directly in the eight bytes of memory associated with each variable.由于这些类型没有固定的大小,它们的值不能直接存储在与每个变量关联的 8 个字节的内存中。 Instead, the variable stores a reference to the value.相反,该变量存储对该值的引用。 Typically, this reference is some form of pointer or memory address.通常,此引用是某种形式的指针或内存地址。 It is not the data value itself, but it tells the variable where to look to find the value.它不是数据值本身,而是告诉变量去哪里寻找值。

The distinction between primitive and reference types is an important one, as they behave differently.原始类型和引用类型之间的区别很重要,因为它们的行为不同。 Consider the following code that uses numbers (a primitive type):考虑以下使用数字(原始类型)的代码:

var a = 3.14;  // Declare and initialize a variable
var b = a;     // Copy the variable's value to a new variable
a = 4;         // Modify the value of the original variable
alert(b)       // Displays 3.14; the copy has not changed

There is nothing surprising about this code.这段代码没有什么令人惊讶的。 Now consider what happens if we change the code slightly so that it uses arrays (a reference type) instead of numbers:现在考虑如果我们稍微更改代码以使用数组(引用类型)而不是数字会发生什么:

var a = [1,2,3];  // Initialize a variable to refer to an array
var b = a;        // Copy that reference into a new variable
a[0] = 99;        // Modify the array using the original reference
alert(b);         // Display the changed array [99,2,3] using the new reference

If this result does not seem surprising to you, you're already well familiar with the distinction between primitive and reference types.如果您对这个结果并不感到惊讶,那么您已经非常熟悉原始类型和引用类型之间的区别。 If it does seem surprising, take a closer look at the second line.如果确实令人惊讶,请仔细查看第二行。 Note that it is the reference to the array value, not the array itself, that is being assigned in this statement.请注意,在此语句中分配的是对数组值的引用,而不是数组本身。 After that second line of code, we still have only one array object;在第二行代码之后,我们仍然只有一个数组对象; we just happen to have two references to it.我们只是碰巧有两个引用它。

As already mentioned in the accepted answer and the highest voted answer, primitive values are data that are stored in stack and reference values are object that are stored in heap.正如在接受的答案和最高投票的答案中已经提到的,原始值是存储在堆栈中的数据,而引用值是存储在堆中的对象。

But what does this actually mean?但这实际上意味着什么? How do they perform differently in your codes?它们在您的代码中的表现有何不同?

Primitive values are accessed by value.通过值访问原始值。 So when you assign an variable (var a) that has a primitive value to another variable (var b), the value of the variable (a) gets copied into the new variable (b).因此,当您将具有原始值的变量 (var a) 分配给另一个变量 (var b) 时,变量 (a) 的值会被复制到新变量 (b) 中。 And when you change the value of the new variable (b), the value of the original variable remain unchanged.而当你改变新变量(b)的值时,原变量的值保持不变。

When you assign a variable (var x) that has a reference value to another variable (var y), the value stored in the variable (x) is also copied into the new variable (y).当您将具有引用值的变量 (var x) 分配给另一个变量 (var y) 时,存储在变量 (x) 中的值也会复制到新变量 (y) 中。 The difference is that the values stored in both variables now are the reference of the actual object stored in the heap.不同之处在于,现在存储在两个变量中的值都是存储在堆中的实际对象的引用。 This means that, both x and y are pointing to the same object.这意味着,x 和 y 都指向同一个对象。 So when you change the value of the new variable (y), the value of the original valuable (x) is also changed (because the actual object in the heap is changed).所以当你改变新变量(y)的值时,原来的value(x)的值也改变了(因为堆中的实际对象改变了)。

原始值是在语言实现的最低级别表示的数据,在 JavaScript 中是以下类型之一:数字、字符串、布尔值、未定义和空值。

Primitive versus reference:原始与参考:

Variable are segments of memory (RAM) which the javascript engine reserves to hold your data.变量是 javascript 引擎为保存数据而保留的内存 (RAM) 段。 Within these variables can be stored 2 kinds of values:在这些变量中可以存储两种值:

  • Actual data: For example a string or number.实际数据:例如字符串或数字。 This means that the actual memory (ie the bytes in memory) hold the data itself.这意味着实际内存(即内存中的字节)保存数据本身。
  • References to objects: For example Array objects or Function objects.对对象的引用:例如数组对象或函数对象。 This means that this variable just holds a reference to another location in memory where this object resides .这意味着这个变量只保存对这个对象所在的内存中另一个位置的引用

Difference between primitive and reference value:原始值和参考值的区别:

When a primitive value gets assigned to a variable the data (values of the bits) just copied.当一个原始值被分配给一个变量时,数据(位的值)就被复制了。 For example:例如:

Primitive values:原始值:

 let num1 = 10; // What happens here is that the bits which are stored in the memory container // (ie variable num1) are literally copied into memory container num2 let num2 = num1;

Reference values:参考值:

 let objRef1 = {prop1: 1} // we are storing the reference of the object which is stored in objRef1 // into objRef2. Now they are pointing to the same object let objRef2 = objRef1; // We are manipulating the object prop1 property via the refernce which // is stored in the variable objRef2 objRef2.prop1 = 2; // The object which objRef1 was pointing to was mutated in the previous action console.log(objRef1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM