Skip to content

Session storage #1941

Answered by Fil
spandl asked this question in Q&A
Mar 8, 2025 · 3 comments
Discussion options

You must be logged in to vote

The issue here is that JSON.parse(JSON.stringify({x})) is not strictly equal to {x}: it's a different object. Instead, you could compare the string representations:

const value = dateRanges.find((d) => JSON.stringify(d) === sessionStorage.getItem("dateRangeType")) ??  dateRanges[0];

Replies: 3 comments

Comment options

Fil
Mar 9, 2025
Collaborator

You must be logged in to vote
0 replies
Answer selected by spandl
Comment options

You must be logged in to vote
0 replies

This comment has been hidden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants