JavaScript Determines if an array is contained within another array.

jQuery
function ArrayContainsArray(arr1, arr2) {
  var doesContain = true;
	
  $.each(arr1, function (){
    var arr1Item = this;       
    var object = $.grep(arr2, function(o){
      return arr1Item == o;
    });

    if (object.length === 0) { doesContain = false; }
  });

return doesContain;
}
Posted by
Snippet Viewed 1255 times.

Share your JavaScript code snippets:

  • Get some recognition & a link back to your site.
  • Create your own code library.
  • Help your fellow developers, as they have helped you.

 

Submit | Browse

Most Recent javascript snippets

Most Viewed