bluehost-banner

How to hide some part of your email using JavaScript

Here we will look, at how we can hide some parts of email id using javascript.

function partialEmail(email) {
    let partialEmail = '';
    if (email) {
      partialEmail = email.replace(/(\w{3})[\w.-]+@([\w.]+\w)/, '$1***@$2');
    }
    return partialEmail;
  }

partialEmail('hello@gmail.com');

Result:

hel***@gmail.com