Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
Object.defineProperty(Array.prototype, 'compare', { value : compareArray } );
function compareArray(other) {
  if (!other || other.length != this.length) return false;
  for (var i=0; i<this.length; i++) if (this[i] !== other[i]) return false;
  return true;
}
var a1 = [1, 2, 3, 4];
var a2 = [1, 2, 3, 4];
var a3 = [1, 2, 5, 6];
var a4 = [1, 2];
console.log(' a1 == a2 : ' + a1.compare(a2));
console.log(' a1 == a3 : ' + a1.compare(a3));
console.log(' a1 == a4 : ' + a1.compare(a4));
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers