Coding⏱️ 3 min read📅 2026-06-04

How to Fix: .includes() not working in Internet Explorer

IE does not support the includes() method. Use a loop instead.

Quick Answer: Use a for...of loop or a traditional for loop to achieve the same result.

The .includes() method is not working in Internet Explorer due to its outdated JavaScript engine. This issue affects users who are using older versions of Internet Explorer, which may not support modern web standards.

This problem can be frustrating for developers and testers who rely on this method to validate string inclusion. However, there are alternative solutions that can help overcome this limitation.

💡 Why You Are Getting This Error

  • The primary reason for this issue is the lack of support for the .includes() method in Internet Explorer's JavaScript engine. This engine is no longer supported by Microsoft and has been removed from newer versions of Internet Explorer.
  • Another possible cause is the use of an older version of Internet Explorer that does not support modern web standards.

🔧 Proven Troubleshooting Steps

Using the .indexOf() method as a workaround

  1. Step 1: To check if a string includes another string, you can use the .indexOf() method instead. The .indexOf() method returns the index of the first occurrence of the specified value, or -1 if it is not found.
  2. Step 2: For example, to check if 'cd' is included in 'abcde', you would use the following code: `var result = 'abcde'.indexOf('cd');`. If the string is found, the method returns its index; otherwise, it returns -1.
  3. Step 3: Keep in mind that this workaround may not be as efficient or readable as using the .includes() method in newer browsers.

Using a custom function to check for inclusion

  1. Step 1: As an alternative solution, you can create a custom function that checks if one string includes another. This approach allows you to avoid relying on the .includes() method altogether.
  2. Step 2: Here is an example of how you could implement this custom function: `function includes(str1, str2) { return str1.indexOf(str2) !== -1; }`. You can then use this function in place of the .includes() method.

💡 Conclusion

In conclusion, while the .includes() method is not supported in Internet Explorer, there are alternative solutions that can help overcome this limitation. By using either the .indexOf() method as a workaround or creating a custom function to check for inclusion, you can ensure that your code works correctly even in older versions of Internet Explorer.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions