Filter array based on dynamic parameter
<p>Say I have an array of json objects which looks like below:</p>

<pre><code>var codes = [{
            "code_id": "1",
            "code_name": "code 1",            ,
             }, {
            "code_id": "2",
            "code_name": "code889",

             },
        // ... () ...    
             ]
</code></pre>

<p>How can I filter codes array based on dynamic input parameter?</p>

<p>So I am looking for a generic function which will take input array and key and value as i/p. </p>

<pre><code>var filteredCodes = getFilteredCodes(codes, "code_id", 2);
</code></pre>

<p>Thanks.</p>