At first glance, the two Sequential models are equivalent. As you wrote, there might be some difference in the optimizer.
However, a more likely explanation for the mismatch you are seeing is that that both
Python Keras and TensorFlow.js initialize the weights of layers such LSTM and Dense randomly.
So by default, you'll get different results every time you run the program, even within the same language and library.
But as an experiment, you can force Keras and TensorFlow.js to use deterministic initializes. This is not a good idea
for solving real ML problems, though. For example, in TensorFlow.js, you can do
* For LSTM, do kernelInitializer: 'ones', recrurrentInitializer: 'ones', biasInitializer: 'zeros'
* For Dense, do kernelInitializer: 'ones', biasInitialize: 'zeros'
The syntax for Keras is similar, just replace the colons with equal signs and replace the camel case with snake case.
Shanqing