It's an interview task that says: Lets imagine, you receive from the backend API 2 very large arrays with names. Your task is to check if values from array t are present in y. Please, explain your approach/es.
var t = ['toy1', 'toy2', 'toy3', ..., A];
var y = ['toy3', 'toy1'];
I want the best method and fastest to compare them, to return true or false or to return index.(whatever) assuming,that they are too large arrays.
Because we don't know if all the array elements are strings or objects(in var t). What is the best aproach?
The best aproach is if all array values are strings to do t.some( name => y.includes(name) );