protect_email = function (user_email) { var avg, splitted, part1, part2; splitted = user_email.split("@"); part1 = splitted[0]; avg = part1.length / 2; part1 = part1.substring(0, (part1.length - avg)); part2 = splitted[1]; return part1 + "...@" + part2; }; console.log(protect_email("robin_singh@example.com"));
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter