Skip to content

Instantly share code, notes, and snippets.

@JerryC8080
Created February 17, 2016 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JerryC8080/85a5344c5a4fa42383eb to your computer and use it in GitHub Desktop.
Save JerryC8080/85a5344c5a4fa42383eb to your computer and use it in GitHub Desktop.
邮箱字符遮罩
/**
* 邮箱字符遮罩
* @param email
* @returns {string}
* @private
*/
function _hideEmail(email) {
var accounts = email.split('@')[0];
var suffix = email.split('@')[1];
var hideNums = Math.floor(accounts.length/2);
var hideAccounts = accounts.split('');
for (var i = 0; i < hideNums; i++) {
hideAccounts[i+1] = '*';
}
return hideAccounts.join('') + '@' + suffix;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment