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”)}

Remove duplicate array based on api response attribute value

Remove duplicate array based on api response attribute value is something different than a normal array. In this post we will find out how we can achieve by comparing attribute value of object array and remove the duplicate array. Remove duplicate array simple In the below code what we are doing is, we loop through […]

HTML5 default validation for confirm password

Hello guys, In this section, I am going to show you how you can easily validating HTML5 default validation for confirm the password. Generally in HTML5 when you create a form you simply write “required” attribute to the form element and it starts validating itself without other javascript code. But for confirm password validation you […]

Nested Loop javascript

Simple nested loop javascript code var person = [{ name : [ {firstName: “Ravi”, lastName: “Kumar”} ], id : 5566 },{ name: [ {firstName: “John”, lastName: “Braman”} ], id : 96 }]; var item, text; text=”<table class=’stack’>”; text+=”<thead><tr><th>First Name</th><th>Last Name</th><th>id</th></tr>”; for(var i=0; i<person.length; i++) { for(var j=0; j<person[i].name.length; j++) { text += “<tr><td>”+person[i].name[j].firstName+”</td><td>”+person[i].name[j].lastName+”</td>”+”<td>”+person[i].id+”</td></tr>”; } } […]