How to find number of keys with certain values in a deep Javascript object?
<p>I have the following deep Javascript object, how do I find the number of '<code>type</code>' keys which have a value of '<code>foo</code>' ?</p>

<pre><code>{
    ...
    blocks: [{
        items: [{
            type: "foo"
        },
        {
            type: "subBlock",
            items: [{
                type: "foo"
            }]
        }]
    },
    {
        items: [{
            type: "foo"
        },
        {
            type: "foo"
        }]
    }]
    ...
}
</code></pre>