Dijktra's Algorithm Visualizer
I don't know if there is a way to avoid the nested loop in this case because you need to do a calc that involves every inner loop index with every outer loop index.
But I think that is not necessary to calculate row * mapWidth in every iteration in the inner loop, once that both variables are available outside it
for (let row = 0; row &lt; mapHeight; row++) {
    //...
    let cached = row * mapWidth;

    for (let column = 0; column &lt; mapWidth; column++) {
        nodeIndex = column + cached;
        let colorIndex = myNodes[nodeIndex].colorIndex;

        //...
    }
//...
}