I worked with this piece of code today:
export class Triangle {
constructor(...sides) {
this.sides = sides;
// returns e.g. [1,2,3] for Triangle(1,2,3)
[this.a, this.b, this.c] = this.sides;
// more code ...
The constructor was given with the spread operator as argument and I couldn't intuitively make sense of it, even tho I use deconstructuring and the spread operator regularly.
Loggin showed me that it results in an Array of whatever was inputed when the class was instantiated. Will that pattern always result in an Array, and if so why ?