A* Search in JavaScript
Having 3 parallel 2D arrays in javascript for simple data is a bit overkill. Put those in a single 2D array or you can fold it into the grid's nodes.

If you want step by step visualization then you'll need to break up your function into sections: init, step and finalize.

init is everything before the main while loop.

step is the while loop body

finalize is only triggered when the loop otherwise breaks or exits.

Whether you group all the data it needs (like pqueue, dist, etc.) into an object that gets passed in or become globals doesn't really matter when it's for educational reasons. But if they are in a single object then it's easier for the visualizer to get that as well.