javascript - Check if the value in array in efficiently -


this question has answer here:

my goal find if value in javascript array, efficiently. understand inarray? check execute in o(n) n length of array because have traverse through every variable in array. hashmap return value in 0(1) (at least understanding)

so if instead of traversing array created key -> variable association, key identical value , tried getting element key. if exists, return true, if 'undefined', return false?

has ever done before , feasible in terms of javascript language?


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -