Is there a more efficient way to achieve these conditions in JavaScript using vanilla or lodash?
const array1 = [1, 2]
const array2 = [1, 2, 3, 4] //true
const array2 = [1, 3, 2, 4] //true
const array2 = [4, 3, 2, 1] //false
const array2 = [2, 3, 1, 4] //false
I have attempted the following approach.
const _ = require('lodash');
const array1 = [1, 2];
const array2 = [1, 2, 3, 4];
const trimmed = array2.filter((n) => combinations.indexOf(n) > -1);
const isEqual = _.isEqualWith(array1, trimmed);
console.log(isEqual);
If you have a cleaner and more flexible solution for this problem, please share.