Nodejs Utililty Methods Array Subset

List of utility methods to do Array Subset

Description

The list of methods to do Array Subset are organized into topic(s).

Method

isSubsetOf(input)
Array.prototype.isSubsetOf = function(input) {
  var freq = {};
  for (var i = 0; i < this.length; i++) {
    freq[this[i]] = 1;
  for (var j = 0; j < input.length; j++) {
    if (freq[input[j]]) {
      delete freq[input[j]];
  return Object.keys(freq).length === 0;
};
isSubsetOf(inputArray)
Array.prototype.isSubsetOf = function(inputArray) {
  var exists = true;
  for (var i = 0; i < this.length; i++) {
    if (inputArray.indexOf(this[i]) === -1) {
      exists = false;
  return exists;
};
...
isSubsetOf(inputArray)
Array.prototype.isSubsetOf = function(inputArray) {
  for (var i = 0; i < this.length; i++) {
    var contains = false;
    for (var j = 0; j < inputArray.length; j++) {
      if (inputArray[j] === this[i]) {
        contains = true;
    if (!contains) {
...
isSubsetOf(matchArr)
Array.prototype.isSubsetOf = function (matchArr) {
  var arr = this;
  for (var i = 0; i < arr.length; i++) {
    if (matchArr.indexOf(arr[i]) === -1 && typeof arr[i] !== 'object') {
      return false;
  return true;
};
...
isSubsetOf(subset)
'use strict';
Array.prototype.isSubsetOf = function(subset){
  var arr = this;
};
isSubsetOfarray()
Array.prototype.isSubsetOf = array => {
  let hash = {};
  let result = true;
  array.forEach(item => {
    hash.item ? hash.item++ : hash.item = 0;
  });
  this.forEach(item => {
    hash.item ? hash.item++ : result = false;
  });
...