Javascript – Creating new instance of the same class as an existing instance, without using eval()
I have an instance sampleInstance of an unknown class and I need to create a second instance of the same class. Here's what I am doing right now: I look up the class name with sampleInstance.constructor.name. Next, I use eval(`new…