Skip to content

Instantly share code, notes, and snippets.

View bhargavkonkathi's full-sized avatar
🏠
Working from home

Bhargav Konkathi bhargavkonkathi

🏠
Working from home
View GitHub Profile
@bhargavkonkathi
bhargavkonkathi / parsecookie.js
Created November 20, 2018 11:34 — forked from rendro/parsecookie.js
Parse document.cookie into object
document.cookie.split(';').map(function(c) {
return c.trim().split('=').map(decodeURIComponent);
}).reduce(function(a, b) {
try {
a[b[0]] = JSON.parse(b[1]);
} catch (e) {
a[b[0]] = b[1];
}
return a;
}, {});