get email domain javascript code example
Example 1: retrieve domain from email address node js
var email = "[email protected]";
var name = email.substring(0, email.lastIndexOf("@"));
var domain = email.substring(email.lastIndexOf("@") +1);
console.log( name ); // john.doe
console.log( domain ); // email.com
Example 2: javascript email link
<body onload="javascript: window.location.href='mailto:[email protected]';">
Example 3: email id domain check javascript
var myemail = '[email protected]'
if (/@yahoo.com\s*$/.test(myemail)) {
console.log("it ends in @yahoo");
}