This feature is currently under development
Don’t worry if someone you don’t want to talk to and they start harassing you by looking online because WhatsApp is going to offer a feature to hide the status of being online very soon.
According to Wabita Info, at first everyone could see your last scene status on WhatsApp, but later WhatsApp introduced a feature to keep it secret at the request of users, but still everyone can see your online status. And consumers were insisting on keeping it secret.
With the latest beta version of the WhatsApp, you’ll be able to hide your online status from everyone, making it easier for people whose friends and family members start texting as soon as they see them online.

According to this screenshot, in the new feature you can decide who can see your online status and there are two options for this.
The first option is Everyone, which if you choose, everyone will be able to see your online status.
The second option is Same as Last Seen, which if you choose, the same option that you have chosen in the Last Seen option will be applied here.
The above screenshots were taken during the preparation of WhatsApp beta for iOS and WhatsApp is planning to introduce this feature on Android and desktop.
This feature is currently in development and no information is currently available about how long it will be available to users.