The in operator checks whether an object has a property, either directly on the object or somewhere in its prototype chain. An expression such as "toString" in obj therefore can be true even when toString was inherited rather than defined directly on obj.
This operator tests property existence, not the value stored in the property. A property whose value is undefined can still make the expression true. The left side is usually a property name string, while the right side must be an object or another suitable object-like value.
The main source of confusion is hasOwnProperty, which is a method rather than an operator. hasOwnProperty checks only an object’s own properties and excludes inherited ones. typeof instead reports a value’s type, while instanceof checks whether an object is linked to a constructor’s prototype. These tools answer related but different questions.