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

Remove redundant nullchecks #5947

Closed
nneeoo opened this issue Oct 11, 2024 · 1 comment
Closed

Remove redundant nullchecks #5947

nneeoo opened this issue Oct 11, 2024 · 1 comment

Comments

@nneeoo
Copy link

nneeoo commented Oct 11, 2024

We can use simple evidence to remove some null checks.
Code like this:

 if (null != n && "function" == typeof n.CompareTo) return n.CompareTo(t);

Could be simplified into this, with null check completely removed.

 if ("function" == typeof n.CompareTo) return n.CompareTo(t);
@alexlamsl
Copy link
Collaborator

The check is not redundant − at least not in Firefox:

var n = null;
typeof n.CompareTo

Uncaught TypeError: n is null

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

No branches or pull requests

2 participants