Blog for web developers

Compare identical array

How to compare identical array

                var userOrder =  ["sort_one","sort_two","sort_three","sort_four","sort_five"];
		var correctOrder = ["sort_one","sort_two","sort_three","sort_four","sort_five"];
		function arraysEqual(arr1, arr2) {
		    if(arr1.length !== arr2.length)
		        return false;
		    for(var i = arr1.length; i--;) {
		        if(arr1[i] !== arr2[i])
		            return false;

		    return true;
if(arraysEqual(correctOrder, userOrder) == true){console.log("array match with position")}else{console.log("not match")}

Santosh Shah

I am a JavaScript developer having enthusiasm on most frontend skills like JavaScript, HTML, CSS, SASS, node, gulp, angular etc. I love exploring new techniques and like to learn new technologies to keep my self up to date.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.