606 B
Executable File
606 B
Executable File
Guard Clauses and Range Validation
A guard clause exits early when input is invalid.
Example from your snippet
if (rangeStart !== undefined && rangeEnd !== undefined && rangeStart > rangeEnd) {
return [];
}
Why this is good
- Fails fast.
- Prevents harder-to-debug logic later.
- Keeps the main flow cleaner.
Operator notes
!==: strict "not equal" comparison.&&: logical AND (all conditions must be true).>: greater-than comparison.
Python comparison
if range_start is not None and range_end is not None and range_start > range_end:
return []