Skip to content

Instantly share code, notes, and snippets.

@4r7ur-sid
4r7ur-sid / share.js
Created October 21, 2022 06:03
JavaScript | Function For Native Sharing on Mobile and Desktop
const _share = (url,title,text)=>{
// Check if native share is supported
if(navigator.share){
navigator.share({
url,
title,
text
})
.then(()=>{
// Analytics event for share
@4r7ur-sid
4r7ur-sid / checkEmail.js
Created November 10, 2022 06:09
JavaScript | Function to check if email is valid and cleanup if required
/*
This function checks if the email is valid and return the email if it is valid or return false if it is not valid
If covers all the modern email formats and top level domains.
*/
const checkEmail = (email, cleanEmail = false) => {
const cleanUp = () => {
// Removing all spaces from the email
email = email.replace(/\s/g, '');