Why are there two exclamation points in the "graphql fullstack tutorial"? Mistake?

// Initializes to true if localStorage includes a 'token' key,
// false otherwise
export const isLoggedInVar = makeVar<boolean>(!!localStorage.getItem('token'));

// Initializes to an empty array
export const cartItemsVar = makeVar<string[]>([]);

Here

Source: Managing local state | Full-Stack Quickstart | Apollo Odyssey

Hello! This is an example of a double NOT operator, which you can use to cast a non-boolean value to a boolean according to its “truthyness”. For more info, check out the MDN docs

3 Likes

Going to leave this here: