Skip to content
Yasser Moradi edited this page Sep 1, 2015 · 2 revisions

Description:

This method returns the smallest values in a sequence. The default overload which has no arguments can be used for numeric sequence

It accepts an argument as a property selector that the selected property should be numeric.

Sample:

let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 19];

let stock = [
  { 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 }
];

let min = numbers.asEnumerable().min();
console.log('Smallest value in numbers collection => ' + min);

let min = numbers.asEnumerable().min();
console.log('Smallest value in numbers collection => ' + min);

min = stock.asEnumerable().min(item => item.price);
console.log(Cheapest in stockitems => ' + min);
Clone this wiki locally