
JavaScript Grew Up and Became a Real Language - prostoalex
https://medium.com/young-coder/how-javascript-grew-up-and-became-a-real-language-17a0b948b77f
======
tanin
Recently, I encountered Cookies API that befuddled me.

For example, to set Cookies:

    
    
        document.cookie = "username=John Smith; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/";
    

To erase it:

    
    
        document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
    

Getting cookie by key involves splitting string and etc.

There must have been some constraint that shaped this API, and I'd love to
learn about that constraint.

If I designed an API like this in a tech interview, nobody would hire me.

~~~
winrid
[https://developer.mozilla.org/en-US/docs/Mozilla/Add-
ons/Web...](https://developer.mozilla.org/en-US/docs/Mozilla/Add-
ons/WebExtensions/API/cookies/set)

Will probably be incorporated across browsers at some point.

document.cookies just isn't a huge pain because every framework provides
abstraction around it. So not many people are motivated to clean it up.

Also, document.cookie is a runtime environement thing and not nessarily tied
to JS.

------
juststeve
is this a meme?

