I'm just curious if document.cookie can ever return undefined.
I read quirksmode's article on cookies and I looked at "Is !document.cookie reliable?" but they don't explicitly answer this question.
Can document.cookie ever be undefined?
2 Answers
The document.cookie property is defined in DOM Level 2, and implemented in every major browser. It sets/gets a string, which may be an empty string (which is falsey, but not undefined).
No.
You can read the spec here
It throws an error if it's set to a value that doesn't adhere to the spec.