Skip to main content

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:

FormWhat it meansWhen it's used
{ age: 25 }an equality checksimple cases
{ age: { $eq: 25 } }an explicit equality operatorwhen 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 ready
Premium

A concise answer to help you respond confidently on this topic during an interview.