Here’s my code
class ImmutableArraySlice<Type> implements Iterable<Type>
{
private _source: Array<Type>;
private _start: number;
private _end: number;
constructor(source: Array<Type> | ImmutableArraySlice<Type>, start: number = 0, end?: number)
{
this._source = ;
this._start = start;
this._end = end ?? source.length;
}
...
}
The problem is that I need to assign different things to this._source
based on the input type, but I don’t know how to do it. I couldn’t google it as I can’t formulate this well enough and, as far as I know, you can’t have multiple constructors in JS/TS, so I’m out of luck here too