Finding angles between two points is a common requirement. For example, you want your character to move or fire in the direction of the mouse cursor, or you want a character to turn to face something on the map.
The method for finding the angle between 2 coordinates is as follows:
function getAngle(x, y, x2, y2)
{
var a = Math.atan2(y2 - y, x2 - x);
return a < 0 ? a + (Math.PI * 2) : a;
}