Using Map[index] vs Using array.filter()

Edit on GitHub

Setup

const map = new Map([[1, 1], [2, 2]])
const array = [1, 1]

Tests

  • Using Map[index]

    const result = map[1]
  • Using array.filter()

    const result = array.find(i => i === 1)