Please note: It only searches for real roots. For complex roots the algorithm of Bairstow or the algorithm using Eigenvalues would be adequate. But these are far to complex to be implemented in JavaScript (I think ).
In case the algorithm does not converge, that can be caused by an unlucky starting point.
Newton Maehly
Order: Starting point
Demo Newton Maehly solver in Java script