Check if each item in an array is identical in javascript -


i need test whether each item in array identical each other. example:

var list = ["l","r","b"]

should evaluate false, because each item not identical. on other hand this:

var list = ["b", "b", "b"]

should evaluate true because identical. efficient (in speed/resources) way of achieving this?

function identical(array) {     for(var = 0; < array.length - 1; i++) {         if(array[i] !== array[i+1]) {             return false;         }     }     return true; } 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -