Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

TS 3.7 Release Notes Nullish Coalescing example wrong #1135

Open
Cristy94 opened this issue Nov 5, 2019 · 0 comments
Open

TS 3.7 Release Notes Nullish Coalescing example wrong #1135

Cristy94 opened this issue Nov 5, 2019 · 0 comments

Comments

@Cristy94
Copy link

Cristy94 commented Nov 5, 2019

https://github.com/microsoft/TypeScript-Handbook/blob/master/pages/release%20notes/TypeScript%203.7.md#nullish-coalescing

I know this was only given as an example, but there's a small mistake:

Screenshot:

image

What is wrong?

It says that let volume = localStorage.volume || 0.5 will be 0.5 when localStorage.volume is set to 0, but everything stored in localStorage can only be a string and "0" is truthy.

localStorage.volume = 0; // saved as "0"
let volume = localStorage.volume || 0.5;  // volume = "0" || 0.5
volume === "0" // Not 0.5 as mentioned in the example
@Cristy94 Cristy94 changed the title TS 3.7 Nullish Coalescing example wrong TS 3.7 Release Notes Nullish Coalescing example wrong Nov 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant