Iam struggling with creating an custom array object type with additional functions, and a class construtor:
The custom array object should have the following content:
["fruits", ["apple", "banana", "pineapple"]]; //array content: string and another array
- I would like to work on such an array with custom functions, like:
Array.prototype.returnArrayContent = function(){
this[1].forEach(element => console.log(element)); }
// But the problem in this case is I add another function to the array prototype, instead
// I would like to a new Object type which inherits all functions, property from built-in-Array-Object
- Because I read in data from JSON file I would like to create those custom array objects with a class constructor like:
new customArrayObject (["fruits", ["apple", "banana", "pineapple"]])
How could this be achieved? As Iam kind of a newbie do I need typescript for this?