0👍
✅
Try parsing the string value to Boolean using JSON:
var cookieCheck = $cookies.get('isDark');
if (cookieCheck === 'undefined') {
cookieCheck = false;
console.log('COOKIE DOESNT EXIST');
} else {
console.log("COOKIE EXISTS")
// if it exists parse the value
cookieCheck = JSON.parse(cookieCheck)
// Check its type
console.log(typeof cookieCheck)
// >> boolean
}
Source:stackexchange.com