Skip to main content
Using != instead of !== can cause unexpected type-coercion and lead to errors / bugs.
Source Link
C. Tewalt
  • 2.5k
  • 2
  • 33
  • 53

This is what you should do. DoPlease do not use stringify nor < >.

function arraysEqual(a, b) { if (a === b) return true; if (a == null || b == null) return false; if (a.length !== b.length) return false; // If you don't care about the order of the elements inside // the array, you should sort both arrays here. // Please note that calling sort on an array will modify that array. // you might want to clone your array first. for (var i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true; } 

This is what you should do. Do not use stringify nor < >.

function arraysEqual(a, b) { if (a === b) return true; if (a == null || b == null) return false; if (a.length !== b.length) return false; // If you don't care about the order of the elements inside // the array, you should sort both arrays here. // Please note that calling sort on an array will modify that array. // you might want to clone your array first. for (var i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true; } 

This is what you should do. Please do not use stringify nor < >.

function arraysEqual(a, b) { if (a === b) return true; if (a == null || b == null) return false; if (a.length !== b.length) return false; // If you don't care about the order of the elements inside // the array, you should sort both arrays here. // Please note that calling sort on an array will modify that array. // you might want to clone your array first. for (var i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true; } 
Using != instead of !== can cause unexpected type-coercion and lead to errors / bugs.
Source Link

This is what you should do. Please don'tDo not use stringify nor < >.

function arraysEqual(a, b) { if (a === b) return true; if (a == null || b == null) return false; if (a.length !=== b.length) return false; // If you don't care about the order of the elements inside // the array, you should sort both arrays here. // Please note that calling sort on an array will modify that array. // you might want to clone your array first. for (var i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true; } 

This is what you should do. Please don't use stringify nor < >.

function arraysEqual(a, b) { if (a === b) return true; if (a == null || b == null) return false; if (a.length != b.length) return false; // If you don't care about the order of the elements inside // the array, you should sort both arrays here. // Please note that calling sort on an array will modify that array. // you might want to clone your array first. for (var i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true; } 

This is what you should do. Do not use stringify nor < >.

function arraysEqual(a, b) { if (a === b) return true; if (a == null || b == null) return false; if (a.length !== b.length) return false; // If you don't care about the order of the elements inside // the array, you should sort both arrays here. // Please note that calling sort on an array will modify that array. // you might want to clone your array first. for (var i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true; } 

This is what you should do. Please don't use stringify nor < >.

function arraysEqual(a, b) { if (a === b) return true; if (a == null || b == null) return false; if (a.length != b.length) return false; // If you don't care about the order of the elements inside // the array, you should sort both arrays here.  // Please note that calling sort on an array will modify that array. // you might want to clone your array first.  for (var i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true; } 

This is what you should do. Please don't use stringify nor < >.

function arraysEqual(a, b) { if (a === b) return true; if (a == null || b == null) return false; if (a.length != b.length) return false; // If you don't care about the order of the elements inside // the array, you should sort both arrays here. for (var i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true; } 

This is what you should do. Please don't use stringify nor < >.

function arraysEqual(a, b) { if (a === b) return true; if (a == null || b == null) return false; if (a.length != b.length) return false; // If you don't care about the order of the elements inside // the array, you should sort both arrays here.  // Please note that calling sort on an array will modify that array. // you might want to clone your array first.  for (var i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true; } 
deleted 1 characters in body
Source Link
enyo
  • 16.9k
  • 10
  • 63
  • 77
Loading
added 125 characters in body
Source Link
enyo
  • 16.9k
  • 10
  • 63
  • 77
Loading
Source Link
enyo
  • 16.9k
  • 10
  • 63
  • 77
Loading