display first 2 elements of array and afer that show a count javascript code example
Example 1: javascript count number of occurrences in array of objects
var result = array.reduce( (acc, o) => (acc[o.name] = (acc[o.name] || 0)+1, acc), {} );
Example 2: javascript count number of occurrences in array of objects
var array =
[
{"name":"abc","age":20}
{"name":"abc","age":20}
{"name":"abc","age":20}
{"name":"xyz","age":21}
{"name":"xyz","age":21}
]