Q:

Access to single values of tensor2d in TensorFlow.js

I'm trying to access the elements of the second row of the 2d matrix using TensorFlow.js package.  Here below I access to the first and second element of the first row of the matrix by using [0] and [1], but honestly I would expect to access those element like [0][0] for get 1 and [1][1] for get 4.  
const t1 = tf.tensor2d([
                         [1,2],
                         [3,4]
                         ]);

    const tensorData = t1.dataSync();
    console.log("data[0] is " + tensorData[0]); // I get 1
    console.log("data[1] is " + tensorData[1]); // I get 2
    console.log("data[0][0] is " + tensorData[0][0]); // I get undefined, but I would expect to get 1

Can someone explain me why?  And how could I can access to the single elements of the second row of the matrix? 

A:

If you want to get the tensor value by coordinate, there is the get method.  Here is an example
const a=tf.tensor([1, 2, 3, 4], [2, 2])
b=a.get(0,0)
console.log(b)

You can also have a look at the following answer

