Javascript Code to trigger focus, focus-within, focus-visible state

Can you please provide any javascript code to run in console and do the same thing as people are doing here manually?

https://stackoverflow.com/questions/4515124/see-hover-state-in-chrome-developer-tools

I tried like,

ele = document.querySelector("#skip-id");
ele.dispatchEvent(new Event('focus'));
ele.dispatchEvent(new Event('focus-visible'));
ele.dispatchEvent(new Event('focus-within'));

but nothing have worked.