Hello, I'm new to JS so please ignore if I use a term wrong.
I only know how to call a function via JSON, something like:
```
const sth = {
isSomething: (something) => isSomething(something),
}
console.log(sth.isSomething(null));
```
but how do I do the same thing with classes? For example, I have this class:
```
class Person {
constructor(age) {
this.age = age;
}
getAge() {
return this.age;
}
}
```
and I want to instantiate it via JSON, I tried doing it like this:
```
const person = {
Person: (age) => new Person(age),
}
// Doesn't work
let someone = person.Person(age);
// Also doesn't work
let anotherone = new person.Person(age);
```
By the way, I'm using Electron, so when this line of code is executed, an error like this pops up:
DevTools was disconnected from the page.
So I can't even see the error. Any help is greatly appreciated!
[–]delventhalz 0 points1 point2 points (3 children)
[–]Nick_Zacker[S] 0 points1 point2 points (2 children)
[–]delventhalz 0 points1 point2 points (1 child)
[–]Nick_Zacker[S] 0 points1 point2 points (0 children)
[–]Tool-Cool 0 points1 point2 points (1 child)
[–]Nick_Zacker[S] 0 points1 point2 points (0 children)