```
var rotate = function(matrix) {
if(matrix.length == 0 || matrix.length != matrix[0].length){
return false;
}
var res = JSON.parse(JSON.stringify(matrix));
n = matrix.length;
for(i=0;i<n;i++){
for(j=n-1;j>-1;j--){
matrix[i][n-j-1] = res[j][i];
}
}
};
```