Is it possible to check if an array
A=[
"EMPRESA",
"CD_MAQ",
"DT_INI_MAQ"
]
Exists in another array
B=[
"EMPRESA",
"CD_MAQ",
"DT_INI_MAQ",
"CD_WKC",
"DT_INI_WKC"
]
I want to check if all entries in array A exists in B
You can use the intersection of the 2 arrays, and then compare to the original.
var A=[
"EMPRESA",
"CD_MAQ",
"DT_INI_MAQ"
];
var B=[
"EMPRESA",
"CD_MAQ",
"DT_INI_MAQ",
"CD_WKC",
"DT_INI_WKC"
];
console.log(_.isEqual(_.intersection(B,A), A));
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.16.2/lodash.js"></script>
You don't need lodash in this case. Here's one liner with vanilla JS.
A.every(i => B.includes(i))
var completeIntersect = _.intersection(A, B).length === A.length;