Skip to content

Unexpected behavior when a or b is 0, which is falsy, causing the error to be thrown even when it should not be.

Notifications You must be signed in to change notification settings

Bug-Hunter-X/Incorrect-Null-Check-in-foo-Function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

This repository contains a JavaScript code example demonstrating an uncommon error related to null checks. The foo function throws an error if either a or b is null. However, this check is overly strict, as it also throws an error when a or b is 0 (a falsy value). This unexpected behavior can be addressed by using the strict equality operator (===) instead of the loose equality operator (==).

About

Unexpected behavior when a or b is 0, which is falsy, causing the error to be thrown even when it should not be.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published