How does $eq differ from plain { field: value }?
There's no difference in the result - $eq just does the same thing, in an explicit form.
An example without an operator:
js
{ age: 25 }This means: find documents where age equals 25.
The same query with $eq:
js
{ age: { $eq: 25 } }What the difference actually is:
| Form | What it means | When it's used |
|---|---|---|
{ age: 25 } | an equality check | simple cases |
{ age: { $eq: 25 } } | an explicit equality operator | when the filter needs other operators too |
In practice { field: value } is shorter and used more often, while $eq is needed when you're building complex queries and combining conditions.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.