title: MongoDB: Arrays size with $where - ReferenceError
body: <p>For MongoDB <em>4.4.6</em></p>
  <p>For a collection with an array - If I use</p>
  <pre><code>db.fighters.find({&quot;close_attacks&quot;: {$size: 3}},
                   {&quot;_id&quot;: 0, &quot;biography&quot;: 0})
             .pretty()
  db.fighters.find({&quot;close_attacks.2&quot; : { $exists: true }},
                   {&quot;_id&quot;: 0, &quot;biography&quot;: 0})
             .pretty()
  db.fighters.find({&quot;close_attacks.3&quot; : { $exists: true }},
                   {&quot;_id&quot;: 0, &quot;biography&quot;: 0})
             .pretty()
  </code></pre>
  <p>All work in peace</p>
  <p>I want work with <code>&gt;=#</code> (i.e <em>&gt;=3</em>), I did do a research, and in many posts in SO appear two options, one already shown above: <em>working with the index of the array and #exists</em>, the other is working with <code>$where</code></p>
  <p>So in Compass through _<em>mongosh beta</em> I tried:</p>
  <pre><code>db.fighters.find({$where: &quot;this.close_attacks.length &gt;= 3&quot;},
                   {&quot;_id&quot;: 0, &quot;biography&quot;: 0})
             .pretty()
  </code></pre>
  <p>and arises</p>
  <pre><code>MongoError: TypeError: this.close_attacks is undefined :
  @:1:15
  </code></pre>
  <p>If I remove <code>this</code></p>
  <pre><code>db.fighters.find({$where: &quot;close_attacks.length &gt;= 3&quot;},
                   {&quot;_id&quot;: 0, &quot;biography&quot;: 0})
             .pretty()
  </code></pre>
  <p>it arises</p>
  <pre><code>MongoError: ReferenceError: close_attacks is not defined :
  @:1:15
  </code></pre>
  <p>What is missing or wrong?</p>