Simple setting retriever from cookies I have a cookie on my site with the following value:


  eyJGIjp0cnVlLCJBIjp0cnVlLCJUIjpmYWxzZSwiUyI6ZmFsc2UsIkciOmZhbHNlLCJYIjpmYWxzZX0%3D


I use this function to retrieve the value from the site so I can use it in the applications my site uses to greenlight certain elements or to block them.

function getCookieLawSettings() {
    return document.cookie.split(';')
            .map(c =&gt; c.trim().split('='))
            .filter(c =&gt; c.shift() == 'cookie_law')
            .map(c =&gt; JSON.parse(atob(decodeURIComponent(c.pop())))).pop()
}


What kind of improvements could I make on this code? Stylistic and functional.
Are there things I missed/gotcha's I should account for?  

sample with dummy data:



document.not_cookie = "_ga=GA1.2.431922604.1523436815; _gid=GA1.2.1579280874.1523436815; cookie_law=eyJGIjp0cnVlLCJBIjp0cnVlLCJUIjpmYWxzZSwiUyI6ZmFsc2UsIkciOmZhbHNlLCJYIjpmYWxzZX0%3D";
function getCookieLawSettings() {
    return document.not_cookie.split(';')
            .map(c =&gt; c.trim().split('='))
            .filter(c =&gt; c.shift() == 'cookie_law')
            .map(c =&gt; JSON.parse(atob(decodeURIComponent(c.pop())))).pop()
}
console.log(getCookieLawSettings());
Since (I assume) there should only be a single cookie fragment called cookie_law you should use find instead of filter. filter will go through the whole array even if the result is the first element.
As it stands I think that it is bad for a filter method to modify the underlying data.
Also the number of parenthesis in the line
.map(c =&gt; JSON.parse(atob(decodeURIComponent(c.pop())))).pop()

is pretty scary. I would pull at least some of that out into another method.
update
In my code I usually split out my logic with a method to get any cookie, that way I can reuse it for other cookies. The logic also ends up being simpler.
function getCookieLawSettings() {
    return decodeCookie(getCookie('cookie_law'));
}

function getCookie(na,e) {
    var cookie = document.cookie.split(';')
            .map(c =&gt; c.trim().split('='))
            .filter(c =&gt; c[0] === name);
    return cookie ? cookie[1] : undefined;
}

function decodeCookie(data) {
    return JSON.parse(atob(decodeURIComponent(data)));
}

function encodeCookie(data) {
    return btoa(encodeURIComponent(JSON.stringify)));
}