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: Manage local state - Apollo Basics - Apollo GraphQL Docs

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: