Pattern: Missing use of contains
Issue: -
Calling indexOf
to see if a collection contains something is difficult to read and may have poor performance. Use contains
instead.
Example of correct code:
if (!lunchBox.contains('sandwich') return 'so hungry...';
Example of incorrect code:
if (lunchBox.indexOf('sandwich') == -1 return 'so hungry...';