<script type="text/javascript">
var arr = [[1,2,3,4,5],
[5,0,7,8,0],
[5,6,7,8,1],
[8,9,9,9,12]];
function Replacer(i,j) {
for(var J in arr[i]){
arr[i][J]=0;
}
for(var I in arr){
arr[I][j]=0;
}
}
TST_arr0=[];
for(var i in arr){
for(var j in arr[i]){
if(arr[i][j]==0){
TST_arr0.push([i,j]);
}
}
}
for(var i in TST_arr0){
Replacer(TST_arr0[i][0],TST_arr0[i][1])
}
</script>
<script>
// Print
var str=''
for(var i in arr){
str+='['+arr[i].join(",")+']\n'
}
alert(str);
</script>