Detect if an element is focused

Assume that ele represents the element that you want to check if it has the focus currently:

const hasFocus = ele === document.activeElement;
Previous
Detect clicks outside of an element
Next
Detect mac os browser