const __print = (x) => console.log(JSON.stringify(x));
let eye = math.matrix([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]);
const __row = (m, r) =>
(([ rows, cols ]) => math.flatten(math.subset(m,
math.index(r, math.range(0, cols))).valueOf()))
(m.size());
const __col = (m, c) =>
(([ rows, cols ]) => math.flatten(math.subset(m,
math.index(math.range(0, rows), c)).valueOf()))
(m.size());
const __cell = (m, r, c) =>
math.subset(m, math.index(r, c));
__print(__cell(eye, 0, 0)); // 1
__print(__row(eye, 0)); // [1, 2, 3]
__print(__row(eye, 1)); // [4, 5, 6]
__print(__row(eye, 2)); // [7, 8, 9]
__print(__col(eye, 0)); // [1, 4, 7]
__print(__col(eye, 1)); // [2, 5, 8]
__print(__col(eye, 2)); // [3, 6, 9]
.as-console-wrapper { top: 0; max-height: 100% !important; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/8.1.1/math.js"></script>