JavaScript TypeError - Cannot use 'in' operator to search for 'X' in 'Y' Last Updated : 19 Aug, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report This JavaScript exception Cannot use 'in' operator to search for 'X' in 'Y' occurs if in operator is used to search in strings, numbers, or other primitive types. It can not be used other than type-checking. Message: TypeError: Invalid operand to 'in' (Edge) TypeError: right-hand side of 'in' must be an object, got 'x' (Firefox) TypeError: cannot use 'in' operator to search for 'x' in 'y' (Firefox, Chrome) Error Type: TypeError Cause of the Error: The in operator can be used only for to check if a property is in an object. This can not be used for search in strings, numbers, or other primitive types. Example 1: in operator can not be used for string search, So the error has occurred. HTML <script> "Geek" in "GeeksForGeeks"; // error here </script> Output: TypeError: Invalid operand to 'in' Example 2: in operator can not be used for string search, So the error has occurred. HTML <script> var gfg = null; "Geek" in gfg; // error here </script> Output: TypeError: Invalid operand to 'in' Comment More infoAdvertise with us Next Article JavaScript Program to Find the Distance Value between Two Arrays P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies javascript-typedArray Similar Reads Explain the purpose of the âinâ operator in JavaScript JavaScript in operator is used to check whether the data is within the object or in an array. In an object, the in operator works only on the key or property of the object. If the key or property exists then this operator returns true otherwise false. Similarly, for arrays, it will return true if we 2 min read JavaScript in Operator JavaScript in operator is an inbuilt operator which is used to check whether a particular property exists in an object or not. It returns a boolean value true if the specified property is in an object, otherwise, it returns false. Syntax:prop in objectParameters: prop: This parameter holds the strin 2 min read JavaScript Program to Find the Distance Value between Two Arrays We will be given two integer arrays and an integer d. The task is to calculate the distance between the two given arrays based on the given integer value. The distance value will be calculated as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i]-arr2[j]| <= 3 min read Python in Keyword The in keyword in Python is a powerful operator used for membership testing and iteration. It helps determine whether an element exists within a given sequence, such as a list, tuple, string, set or dictionary.Example:Pythons = "Geeks for geeks" if "for" in s: print("found") else: print("not found") 3 min read Python program to find String in a List Searching for a string in a list is a common operation in Python. Whether we're dealing with small lists or large datasets, knowing how to efficiently search for strings can save both time and effort. In this article, weâll explore several methods to find a string in a list, starting from the most e 3 min read JavaTuples containsAll() method The containsAll() method in org.javatuples is used to check whether a collection of values is present in the TupleClass, given as parameters. This method can be used for any tuple class object of the javatuples library. It returns a boolean value that is true or false based on the presence of that c 3 min read Like