Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions source/reference/method/cursor.forEach.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,7 @@ cursor.forEach()

JavaScript function to apply to each document from the
cursor. The ``<function>`` signature includes a single argument
that is passed the current document to process, as in the
following prototype:

.. code-block:: javascript

function(doc) {
...
}

However, if the signature is missing the argument, you can
access the document using the reserved
``arguments`` [#arguments]_ variable within the function,
specifically ``arguments[0]``, as in the following prototype:

.. code-block:: javascript

function() {
doc = arguments[0];
...
}

.. [#arguments] The ``arguments`` variable is an array
and thus, you can access ``arguments.length`` attribute to
determine the number of arguments.
that is passed the current document to process.

The following example invokes the :method:`~cursor.forEach()` method
on the cursor returned by :method:`~db.collection.find()` to print
Expand Down