====
each
====

.. js:function:: each(function(item))

**domain**: client 

**language**: javascript

**class** :doc:`Item class </refs/client/item_api>`

Description
===========

Use each method to iterate over records of an item dataset.

The each() method specifies a function to run for each record.
You can break the each loop at a particular iteration by making the callback 
function return ``false``. 

Example
=======

In the example below the **t** and **item.invoice_table** are pointers to the
same object:

.. code-block:: js

    var subtotal = 0,
        tax = 0,
        total = 0;
    item.invoice_table.each(function(t) {
        subtotal += t.amount.value;
        tax += t.tax.value;
        total += t.total.value;
    });

See also
========

:doc:`Navigating datasets </programming/data/navigating_datasets>`
