atan2(cross, dot) gives the signed angle from a to b in the range (−π, π]. Using both products together is robust where acos(dot / (|a||b|)) loses precision near 0 and ±π.
See also: Dot product as projection and 2D cross product — the two ingredients.
dot = a.x * b.x + a.y * b.y
cross = a.x * b.y - a.y * b.x
angle = atan2(cross, dot) // signed, in (-π, π]
const ox = 150, oy = 150
const ax = 90, ay = 0
const bx = mouseX - ox
const by = mouseY - oy
const dot = ax * bx + ay * by
const cross = ax * by - ay * bx
const angle = Math.atan2(cross, dot)