I'm new to JavaScript. Just a question on using the spread operator on a class function. An example:

```js
let personA = {
  name: "Tom",
  testFunction: function() {
    // ...
  }
};
let newArray = [];
newArray.push({ ...personA });
console.log(newArray);
```

And the output is:

> 
> 
> ```
> [{ name: 'Tom', testFunction: F}]
> 
> ```
> 
> 

But if I use a class, such as:

```js
class Person {
    constructor(name) { 
        this.name = name;
    }
    testFunction() {

    }
}

let personA = new Person("Tom");
let newArray= [];
newArray.push({...personA});
console.log(newArray);
```

The output is:

> 
> 
> ```
> [{ name: 'Tom'}]
> 
> ```
> 
> 

So the function is missing.
Isn't everything in JS an object? So why can I use the rest operator to get the method when using object literals but not with a class?