js check if string is base64

Solutions on MaxInterview for js check if string is base64 by the best coders in the world

showing results for - "js check if string is base64"
Dario
12 Jun 2018
1function isBase64(str) {
2    if (str ==='' || str.trim() ===''){ return false; }
3    try {
4        return btoa(atob(str)) == str;
5    } catch (err) {
6        return false;
7    }
8}
9