You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This method returns the numbers of item in the collection.
It has a predicate argument and returns number of items in the collection which pass the predicate.
Samples:
letstock=[{name: 'Apple',category: 'Fruit',price: 0.30},{name: 'Banana',category: 'Fruit',price: 0.35},{name: 'Orange',category: 'Fruit',price: 0.29},{name: 'Cabbage',category: 'Vegetable',price: 0.49},{name: 'Carrot',category: 'Vegetable',price: 0.29},{name: 'Lettuce',category: 'Vegetable',price: 0.30},{name: 'Milk',category: 'Dairy',price: 1.12}];console.log('stock item count => '+stock.asEnumerable().count());console.log('Number of stockItems which are Fruit => '+stock.asEnumerable().count(item=>item.category=='Fruit'));/*This code: */stock.asEnumerable().count(item=>item.category=='Fruit')/* is equivalent to */stock.asEnumerable().where(item=>item.category=='Fruit').count()