I decided to use javascript indexOf to determine if a value exists in a list / array. This was working for me untill I realised that I need to find an exact match in the list.
Here is my example code:
if (['eu', 'fr-CA', 'lt', 'sv', 'zh-CN', 'zh-TW'].indexOf('fr') > -1) {
The above code will 'match' fr to fr-CA, which is a problem for me, as I must have an exact match to fr and not match to fr-CA.
I thought that this would be straight forward, but I have searched SO and google, and cannot find an answer to getting the exact match.