in 运算符 Property existence check
Last updated: 2026-09-09
in 运算符 Property existence check
in checks whether a property exists on an object (including the prototype chain).
| Category | Operators |
|---|---|
| ES version | ES1 |
📝 Syntax
"key" in obj;
Returns:A boolean.
Mutates the original:No (returns a new value)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
true
false
true
true
false
⚠️ Warning in checks the prototype chain — use Object.hasOwn() for own properties only.
ℹ️ info in checks array indices, not values — use includes for values.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| in 运算符 | ✓ v1 | ✓ v12 | ✓ v1 | ✓ v1 | ✓ v1 |
| Supported by all modern browsers | |||||
🏷️ Related Operators
💡 Related Cases
More case studies coming soon — check back later.
📚 Related Tutorials
❓ FAQ
Qin vs Object.hasOwn?
Ain includes the prototype chain; Object.hasOwn checks own only.
QWhat does in check on arrays?
AIndices, not values. Use includes for values.
QDoes in work with Symbols?
AYes — Symbol keys work with in.