How to define type of an object whose properties are going to be fetched from an array in TypeScript.
In the following example, how can I define the type of lookUpMap object?
const arr1 = ["a", "b", "c", "d"];
const arr2 = ["x", "y", "b"];
class Arr {
private lookUpMap = {}
constructor(private arr1: string[], private arr2: string[]){}
linearCompare(){
for(let i of this.arr1){
this.lookUpMap[i] = true
}
for(let i of this.arr2){
if(this.lookUpMap[i]){
return console.log(true);
}
}
return console.log(false);
}
}
const arrComp = new Arr(arr1, arr2);
arrComp.linearCompare()
Thank you