I am having a strange javascript result with array.includes() not finding a match [closed]

6 days ago 6
ARTICLE AD BOX

I changed the list to a Map and then to a Set (never used Set before). Got same issue on that 3rd entry!

I again inspected the datalist and now noticed the space at end of that third one that was causing the validation issue. Switched to debugging the back-end queries and found in SQL Server where querying for distinct list of values. Results only had value with a trailing space.

But a test query where I used

SELECT DISTINCT CONCAT ('''', MyColumn,'''')

returns values both with and without a trailing space. So while server-side validation works, the distinct list sent to the client only had the value with the space. And the form was loaded with a record with a value that didn't have a space. I assume that users has just never tried editing that record before.

What a time suck. But I did figure it out.

Read Entire Article