How to convert a multidimensional JavaScript array to JSON?

To convert a multidimensional JavaScript array to JSON, we use the JSON.stringify method.

For instance, we write

const arr = [
  [1, 2, 3],
  [4, 5, 6],
];
const json = JSON.stringify(arr);

to call JSON.stringify with arr multidimensional array to convert arr into a JSON string.