Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix .reset() to correctly handle falsy default values #141

Merged
merged 7 commits into from
Feb 7, 2021

Conversation

kamontat
Copy link
Contributor

@kamontat kamontat commented Feb 4, 2021

Problem

Currently condition to use whether default value or undefined, is not accuracy.

if (value) {

}

The if condition with plain object in condition field will return false on falsy value including zero number (0), empty string (""), and false value of boolean (false). which on this case it might be actual default value.

Solution

So I create new function to help checking existing of variable which will check only not undefined and not null value

@sindresorhus sindresorhus changed the title fix: clear items should initial empty string and zero number Fix .reset() to correctly handle falsy default values Feb 7, 2021
@sindresorhus sindresorhus merged commit 735225e into sindresorhus:main Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants