[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Errors/in_operator_no_object [Back]  [Original]

TypeError: cannot use 'in' operator to search for 'x' in 'y' - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

TypeError: cannot use 'in' operator to search for 'x' in 'y'

JavaScript "right-hand side of 'in' should be an object" in

js
TypeError: Invalid operand to 'in' (Edge)
TypeError: right-hand side of 'in' should be an object, got 'x' (Firefox)
TypeError: cannot use 'in' operator to search for 'x' in 'y' (Firefox, Chrome)

TypeError

in

(Python ) in

js
"Hello" in "Hello World";
// TypeError: cannot use 'in' operator to search for 'Hello' in 'Hello World'

String.prototype.indexOf()

js
"Hello World".indexOf("Hello") !== -1;
// true

null undefined

null undefined

js
var foo = null;
"bar" in foo;
// TypeError: cannot use 'in' operator to search for 'bar' in 'foo' (Chrome)
// TypeError: right-hand side of 'in' should be an object, got null (Firefox)

in

js
var foo = { baz: "bar" };
"bar" in foo; // false

"PI" in Math; // true
"pi" in Math; // false

in Array in

js
var trees = ["redwood", "bay", "cedar", "oak", "maple"];
3 in trees; // true
"oak" in trees; // false


Web Proxy Viewer  |  New URL  |  Original Page