Skip to content
Advertisement

How to save the name of object in array object?

I have an array containing 7 objects named is NewClass.

enter image description here

When I make some changes to the objects, the object has lost its original NewClass name.

Like that:

enter image description here

In arrray[6] lost NewClass name.

So is there any way I can keep the NewClass name for that object?

Here is my function to handle this array:

JavaScript

}, [selectedLayerIndex]);

Thank you so much!

Advertisement

Answer

by using the syntax x = {...x, option: {/* some changes to the class */} here, you change the class to a object, which cause a lost of your class name.

If you want to keep it as a class, please use instance.attribute instead, see the following example

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement