[ 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

TypeError: Cannot use 'in' operator to search for 'x' in 'y' (V8-based & Firefox)
TypeError: right-hand side of 'in' should be an object, got null (Firefox)
TypeError: "y" is not an Object. (evaluating '"x" in "y"') (Safari)

TypeError

in

(Python ) in

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

String.prototype.includes()

js
"Hello World".includes("Hello");
// true

null undefined

null undefined

js
const 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
const foo = { baz: "bar" };
"bar" in foo; // false

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

in Array in

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


Web Proxy Viewer  |  New URL  |  Original Page