I’ve grown spoiled by ColdFusion’s lists, and have run across a situation or two where a comma delimited list shows up in Javascript. Is there an equivalent of listFindNoCase('string','list'), or a performant way to implement it in Javascript?
Oh, and it should be able to handle list items with commas, like:
( “Smith, John” , “Doe, Jane” , “etc…” )
That’s what is really tripping me up.
You can use
indexOfcombined with.toLowerCase()If you need an exact match, like “Smith” when “Smithson” exists, just pad the strings with your delimiter. For example, let’s say your delimiter is a semi-colon (because you have commas in your string), pad the left and right sides of your string like so:
Also pad the search value, so if you’re looking for Smith, the value would become:
.toLowerCase().indexOf()would return -1 (not found). But";Smith, John;"would return 0