I'd like to compare (a limited number of) color values retrieved from an HTML5 canvas. So I retrieve and store what I'm interested in by ctx.getImageData(x, y, 1, 1).data;
I then tried to use the Array.prototype.compare
from: How to compare arrays in JavaScript? by:
// add the same compare method to Uint8ClampedArray
Uint8ClampedArray.prototype.compare=Array.prototype.compare;
That works fine on recent FireFox and Chrome but I soon found that not all browsers return an object of type Uint8ClampedArray. IE seems to use an Object of CanvasPixelArray and Safari seems to use a simple 4-value array
Do I have to deal with those differences myself or is there a reliable generelized method (plain JS or jQuery) to compare two such values retieved by ctx.getImageData() that works on all browsers?