I need to check if a particular value exists in the main array.
Example:
var hideFilters = function() {
    var listCategoryId = ['1000014', '1000015', '1000016', '1000017', '1000018', '1000019', '1000021', '1000086'];
    var actualCategoryId = '1000018';
    if (actualCategoryId === listCategoryId) {
        console.log('is equal');
    } else {
        console.log('fuen... fuen...');
    }
};
hideFilters();
                if(listCategoryId.indexOf(actualCategoryId) != -1) {
  console.log('exists')
}
                        If Array.prototype.indexOf() returns an index greater or equal 0, the array contains the specified element. Otherwise it will return -1:
var hideFilters = function() {
  var listCategoryId = ['1000014', '1000015', '1000016', '1000017', '1000018', '1000019', '1000021', '1000086'];
  var actualCategoryId = '1000018';
  if (listCategoryId.indexOf(actualCategoryId) > -1) {
    console.log('is equal');
  } else {
    console.log('fuen... fuen...');
  }
};
hideFilters();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With