linq.js
function elementAt(index, defaultValue) {
  let i = 0;

  for (let item of this) {
    if (i === index) return item;
    i++;
  }

  return defaultValue;
}
function elementAt(index, defaultValue) {
  let i = 0;

  for (let item of this) {
    if (i === index) return item;
    i++;
  }

  return defaultValue;
}
function elementAt ( index , defaultValue ) { let i = 0 ; for ( let item of this ) { if ( i === index ) return item ; i ++ ; } return defaultValue ; }
Returns the element at a specified index in a sequence.

@param positon The zero-base index of element which you want.
@param defaultValue The default value if the index is out of range.
@return The element at a specified index or default value
Returns the element at a specified index in a sequence .