Array filter and callback functions
<html> <head> <title>Array filter and callback functions</title> </head> <body> <script type="text/javascript"> function checkColor(element,index,array) { return (element >= 0 && element < 256); } var colors = new Array( ); colors[0] = [0,262,255]; colors[4] = [0,0,255]; colors[5] = [-5,567,255]; var testedColors = new Array( ); for (var i in colors) { testedColors[i] = colors[i].filter(checkColor); document.write(testedColors[i]); } </script> </body> </html>
Related examples in the same category