Always use consistent patterns and utility functions for handling null and undefined values. This improves code reliability and maintainability while preventing common errors.
Always use consistent patterns and utility functions for handling null and undefined values. This improves code reliability and maintainability while preventing common errors.
Key guidelines:
Example:
// ❌ Avoid direct null/undefined checks
if (typeof value === 'undefined' || value === null) {
// ...
}
// ✅ Use utility functions
if (utils.isUndefined(value) || utils.isNull(value)) {
// ...
}
// ❌ Avoid setting null for collections
this.handlers = null;
// ✅ Use empty collections instead
this.handlers = [];
// ❌ Avoid unsafe property access
if (payload && payload.isAxiosError) {
// ...
}
// ✅ Use comprehensive null checks
if (!!payload && typeof payload === 'object' && payload.isAxiosError) {
// ...
}
Enter the URL of a public GitHub repository